AsmResolver.Net.DefaultMetadataResolver.ResolveType C# (CSharp) Method

ResolveType() public method

public ResolveType ( ITypeDescriptor type ) : TypeDefinition
type ITypeDescriptor
return TypeDefinition
        public TypeDefinition ResolveType(ITypeDescriptor type)
        {
            if (type == null)
                throw new ArgumentNullException("type");
            type = type.GetElementType();

            var typeDef = type as TypeDefinition;
            if (typeDef != null)
                return typeDef;

            var assemblyDescriptor = type.ResolutionScope.GetAssembly();
            if (assemblyDescriptor == null)
                return (TypeDefinition)ThrowOrReturn(type);

            var assembly = AssemblyResolver.ResolveAssembly(assemblyDescriptor);
            if (assembly == null)
                return (TypeDefinition)ThrowOrReturn(type);

            var typeDefTable = assembly.Header.GetStream<TableStream>().GetTable<TypeDefinition>();
            if (typeDefTable == null)
                return (TypeDefinition)ThrowOrReturn(type);

            var definition = typeDefTable.FirstOrDefault(x => _signatureComparer.MatchTypes(x, type));
            return definition ?? (TypeDefinition)ThrowOrReturn(type);
        }