ResolveType() private method

private ResolveType ( TypeName typeName ) : Type
typeName TypeName
return Type
Exemplo n.º 1
0
 private Type ImportMscorlibType(System.Type type)
 {
     if (Mscorlib.__IsMissing)
     {
         return(Mscorlib.ResolveType(new TypeName(type.Namespace, type.Name)));
     }
     // We use FindType instead of ResolveType here, because on some versions of mscorlib some of
     // the special types we use/support are missing and the type properties are defined to
     // return null in that case.
     // Note that we don't have to unescape type.Name here, because none of the names contain special characters.
     return(Mscorlib.FindType(new TypeName(type.Namespace, type.Name)));
 }
Exemplo n.º 2
0
 private Type ResolvePrimitive(string name)
 {
     // Primitive here means that these types have a special metadata encoding, which means that
     // there can be references to them without refering to them by name explicitly.
     // When 'resolve missing type' mode is enabled, we want these types to be usable even when
     // they don't exist in mscorlib or there is no mscorlib loaded.
     return(Mscorlib.ResolveType(new TypeName("System", name)));
 }
Exemplo n.º 3
0
        internal Type GetType(Universe universe, Assembly context, bool throwOnError, string originalName, bool resolve)
        {
            TypeName name = TypeName.Split(this.name);
            Type     type;

            if (assemblyName != null)
            {
                Assembly asm = universe.Load(assemblyName, context, throwOnError);
                if (asm == null)
                {
                    return(null);
                }
                if (resolve)
                {
                    type = asm.ResolveType(name);
                }
                else
                {
                    type = asm.FindType(name);
                }
            }
            else if (context == null)
            {
                if (resolve)
                {
                    type = universe.Mscorlib.ResolveType(name);
                }
                else
                {
                    type = universe.Mscorlib.FindType(name);
                }
            }
            else
            {
                type = context.FindType(name);
                if (type == null && context != universe.Mscorlib)
                {
                    type = universe.Mscorlib.FindType(name);
                }
                if (type == null && resolve)
                {
                    if (universe.Mscorlib.__IsMissing && !context.__IsMissing)
                    {
                        type = universe.Mscorlib.ResolveType(name);
                    }
                    else
                    {
                        type = context.ResolveType(name);
                    }
                }
            }
            return(Expand(type, context, throwOnError, originalName, resolve));
        }
Exemplo n.º 4
0
        internal Type GetType(Universe universe, Module context, bool throwOnError, string originalName, bool resolve, bool ignoreCase)
        {
            Debug.Assert(!resolve || !ignoreCase);
            TypeName name = TypeName.Split(this.name);
            Type     type;

            if (assemblyName != null)
            {
                Assembly asm = universe.Load(assemblyName, context, throwOnError);
                if (asm == null)
                {
                    return(null);
                }
                if (resolve)
                {
                    type = asm.ResolveType(context, name);
                }
                else if (ignoreCase)
                {
                    type = asm.FindTypeIgnoreCase(name.ToLowerInvariant());
                }
                else
                {
                    type = asm.FindType(name);
                }
            }
            else if (context == null)
            {
                if (resolve)
                {
                    type = universe.Mscorlib.ResolveType(context, name);
                }
                else if (ignoreCase)
                {
                    type = universe.Mscorlib.FindTypeIgnoreCase(name.ToLowerInvariant());
                }
                else
                {
                    type = universe.Mscorlib.FindType(name);
                }
            }
            else
            {
                if (ignoreCase)
                {
                    name = name.ToLowerInvariant();
                    type = context.FindTypeIgnoreCase(name);
                }
                else
                {
                    type = context.FindType(name);
                }
                if (type == null && context != universe.Mscorlib.ManifestModule)
                {
                    if (ignoreCase)
                    {
                        type = universe.Mscorlib.FindTypeIgnoreCase(name);
                    }
                    else
                    {
                        type = universe.Mscorlib.FindType(name);
                    }
                }
                if (type == null && resolve)
                {
                    if (universe.Mscorlib.__IsMissing && !context.__IsMissing)
                    {
                        type = universe.Mscorlib.ResolveType(context, name);
                    }
                    else
                    {
                        type = context.Assembly.ResolveType(context, name);
                    }
                }
            }
            return(Expand(type, context, throwOnError, originalName, resolve, ignoreCase));
        }