FindType() abstract private method

abstract private FindType ( TypeName name ) : Type
name TypeName
return Type
Ejemplo 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)));
 }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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));
        }