private bool TryResolveNamespaceDefinitionCaseSensitive(MetadataReader reader, string[] namespaceParts, ScopeDefinitionHandle scopeDefinitionHandle, out NamespaceDefinition namespaceDefinition)
        {
            namespaceDefinition = scopeDefinitionHandle.GetScopeDefinition(reader).RootNamespaceDefinition.GetNamespaceDefinition(reader);
            NamespaceDefinitionHandleCollection candidates = namespaceDefinition.NamespaceDefinitions;
            int idx = namespaceParts.Length;

            while (idx-- != 0)
            {
                // Each iteration finds a match for one segment of the namespace chain.
                string expected   = namespaceParts[idx];
                bool   foundMatch = false;
                foreach (NamespaceDefinitionHandle candidate in candidates)
                {
                    namespaceDefinition = candidate.GetNamespaceDefinition(reader);
                    if (namespaceDefinition.Name.StringOrNullEquals(expected, reader))
                    {
                        // Found a match for this segment of the namespace chain. Move on to the next level.
                        foundMatch = true;
                        candidates = namespaceDefinition.NamespaceDefinitions;
                        break;
                    }
                }

                if (!foundMatch)
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #2
0
 public static IEnumerable <NamespaceDefinitionHandle> AsEnumerable(this NamespaceDefinitionHandleCollection collection)
 {
     foreach (NamespaceDefinitionHandle handle in collection)
     {
         yield return(handle);
     }
 }
Beispiel #3
0
 public static IEnumerable <NamespaceDefinitionHandle> AsEnumerable(this NamespaceDefinitionHandleCollection collection)
 {
     foreach (var element in collection)
     {
         yield return(element);
     }
 }
Beispiel #4
0
        } // Read

        public static uint Read(this NativeReader reader, uint offset, out NamespaceDefinitionHandleCollection values)
        {
            values = new NamespaceDefinitionHandleCollection(reader, offset);
            uint count;

            offset = reader.DecodeUnsigned(offset, out count);
            for (uint i = 0; i < count; ++i)
            {
                offset = reader.SkipInteger(offset);
            }
            return(offset);
        } // Read
Beispiel #5
0
        public static NamespaceDefinitionHandle Single(this NamespaceDefinitionHandleCollection collection)
        {
            Debug.Assert(collection.Count == 1);
            var  enumerator = collection.GetEnumerator();
            bool hasNext    = enumerator.MoveNext();

            Debug.Assert(hasNext);
            var result = enumerator.Current;

            Debug.Assert(!enumerator.MoveNext());
            return(result);
        }
Beispiel #6
0
        } // Read

        public static uint Read(this NativeReader reader, uint offset, out NamespaceDefinitionHandleCollection values)
        {
            values = new NamespaceDefinitionHandleCollection(reader, offset);
            uint count;
            offset = reader.DecodeUnsigned(offset, out count);
            for (uint i = 0; i < count; ++i)
            {
                offset = reader.SkipInteger(offset);
            }
            return offset;
        } // Read