System.Dynamic.ExpandoClass.GetValueIndexCaseSensitive C# (CSharp) Méthode

GetValueIndexCaseSensitive() private méthode

Gets the index at which the value should be stored for the specified name case sensitively. Returns the index even if the member is marked as deleted.
private GetValueIndexCaseSensitive ( string name ) : int
name string
Résultat int
        internal int GetValueIndexCaseSensitive(string name)
        {
            for (int i = 0; i < _keys.Length; i++)
            {
                if (string.Equals(
                    _keys[i],
                    name,
                    StringComparison.Ordinal))
                {
                    return i;
                }
            }
            return ExpandoObject.NoMatch;
        }

Usage Example

Exemple #1
0
            /// <summary>
            /// Gets the class and the index associated with the given name.  Does not update the expando object.  Instead
            /// this returns both the original and desired new class.  A rule is created which includes the test for the
            /// original class, the promotion to the new class, and the set/delete based on the class post-promotion.
            /// </summary>
            private ExpandoClass GetClassEnsureIndex(string name, bool caseInsensitive, ExpandoObject obj, out ExpandoClass klass, out int index)
            {
                ExpandoClass originalClass = Value.Class;

                index = originalClass.GetValueIndex(name, caseInsensitive, obj);
                if (index == ExpandoObject.AmbiguousMatchFound)
                {
                    klass = originalClass;
                    return(null);
                }
                if (index == ExpandoObject.NoMatch)
                {
                    // go ahead and find a new class now...
                    ExpandoClass newClass = originalClass.FindNewClass(name);

                    klass = newClass;
                    index = newClass.GetValueIndexCaseSensitive(name);

                    Debug.Assert(index != ExpandoObject.NoMatch);
                    return(originalClass);
                }
                else
                {
                    klass = originalClass;
                    return(null);
                }
            }