Exemple #1
0
 public static IEnumerable <TypeDefinitionHandle> AsEnumerable(this TypeDefinitionHandleCollection collection)
 {
     foreach (TypeDefinitionHandle handle in collection)
     {
         yield return(handle);
     }
 }
Exemple #2
0
 public static IEnumerable <TypeDefinitionHandle> AsEnumerable(this TypeDefinitionHandleCollection collection)
 {
     foreach (var element in collection)
     {
         yield return(element);
     }
 }
        internal sealed override RuntimeTypeInfo UncachedGetTypeCoreCaseSensitive(string fullName)
        {
            string[] parts             = fullName.Split('.');
            int      numNamespaceParts = parts.Length - 1;

            string[] namespaceParts = new string[numNamespaceParts];
            for (int i = 0; i < numNamespaceParts; i++)
            {
                namespaceParts[numNamespaceParts - i - 1] = parts[i];
            }
            string name = parts[numNamespaceParts];

            foreach (QScopeDefinition scopeDefinition in AllScopes)
            {
                MetadataReader        reader = scopeDefinition.Reader;
                ScopeDefinitionHandle scopeDefinitionHandle = scopeDefinition.Handle;

                NamespaceDefinition namespaceDefinition;
                if (!TryResolveNamespaceDefinitionCaseSensitive(reader, namespaceParts, scopeDefinitionHandle, out namespaceDefinition))
                {
                    continue;
                }

                // We've successfully drilled down the namespace chain. Now look for a top-level type matching the type name.
                TypeDefinitionHandleCollection candidateTypes = namespaceDefinition.TypeDefinitions;
                foreach (TypeDefinitionHandle candidateType in candidateTypes)
                {
                    TypeDefinition typeDefinition = candidateType.GetTypeDefinition(reader);
                    if (typeDefinition.Name.StringEquals(name, reader))
                    {
                        return(candidateType.ResolveTypeDefinition(reader));
                    }
                }

                // No match found in this assembly - see if there's a matching type forwarder.
                TypeForwarderHandleCollection candidateTypeForwarders = namespaceDefinition.TypeForwarders;
                foreach (TypeForwarderHandle typeForwarderHandle in candidateTypeForwarders)
                {
                    TypeForwarder typeForwarder = typeForwarderHandle.GetTypeForwarder(reader);
                    if (typeForwarder.Name.StringEquals(name, reader))
                    {
                        RuntimeAssemblyName redirectedAssemblyName = typeForwarder.Scope.ToRuntimeAssemblyName(reader);
                        RuntimeAssemblyInfo redirectedAssembly     = RuntimeAssemblyInfo.GetRuntimeAssemblyIfExists(redirectedAssemblyName);
                        if (redirectedAssembly == null)
                        {
                            return(null);
                        }
                        return(redirectedAssembly.GetTypeCoreCaseSensitive(fullName));
                    }
                }
            }

            return(null);
        }
Exemple #4
0
        } // Read

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

            offset = reader.DecodeUnsigned(offset, out count);
            for (uint i = 0; i < count; ++i)
            {
                offset = reader.SkipInteger(offset);
            }
            return(offset);
        } // Read
Exemple #5
0
        public static TypeDefinitionHandle Single(this TypeDefinitionHandleCollection 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);
        }
Exemple #6
0
        } // Read

        public static uint Read(this NativeReader reader, uint offset, out TypeDefinitionHandleCollection values)
        {
            values = new TypeDefinitionHandleCollection(reader, offset);
            uint count;
            offset = reader.DecodeUnsigned(offset, out count);
            for (uint i = 0; i < count; ++i)
            {
                offset = reader.SkipInteger(offset);
            }
            return offset;
        } // Read
 public static TypeDefinition GetType(this TypeDefinitionHandleCollection typeDefHandles, MetadataReader reader,
                                      string ns, string typeName) => typeDefHandles
 .Select(reader.GetTypeDefinition)
 .First(t => reader.GetString(t.Name) == typeName && reader.GetString(t.Namespace) == ns);