public virtual TypeDefinition Resolve(TypeReference type)
        {
            Mixin.CheckType(type);

            type = type.GetElementType();

            var scope = type.Scope;

            if (scope == null)
            {
                return(null);
            }

            switch (scope.MetadataScopeType)
            {
            case MetadataScopeType.AssemblyNameReference:
                var assembly = assembly_resolver.Resolve((AssemblyNameReference)scope);
                if (assembly == null)
                {
                    return(null);
                }

                return(GetType(assembly.MainModule, type));

            case MetadataScopeType.ModuleDefinition:
                return(GetType((ModuleDefinition)scope, type));

            case MetadataScopeType.ModuleReference:
                var modules    = type.Module.Assembly.Modules;
                var module_ref = (ModuleReference)scope;
                for (int i = 0; i < modules.Count; i++)
                {
                    var netmodule = modules [i];
                    if (netmodule.Name == module_ref.Name)
                    {
                        return(GetType(netmodule, type));
                    }
                }
                break;
            }

            throw new NotSupportedException();
        }
예제 #2
0
        static void AppendType(TypeReference type, StringBuilder name, bool fq_name, bool top_level)
        {
            var element_type = type.GetElementType();

            var declaring_type = element_type.DeclaringType;

            if (declaring_type != null)
            {
                AppendType(declaring_type, name, false, top_level);
                name.Append('+');
            }

            var @namespace = type.Namespace;

            if (!string.IsNullOrEmpty(@namespace))
            {
                AppendNamePart(@namespace, name);
                name.Append('.');
            }

            AppendNamePart(element_type.Name, name);

            if (!fq_name)
            {
                return;
            }

            if (type.IsTypeSpecification())
            {
                AppendTypeSpecification((TypeSpecification)type, name);
            }

            if (RequiresFullyQualifiedName(type, top_level))
            {
                name.Append(", ");
                name.Append(GetScopeFullName(type));
            }
        }
예제 #3
0
 public override TypeReference GetElementType()
 {
     return(element_type.GetElementType());
 }
예제 #4
0
        private static bool IsRedirectedType(TypeReference type)
        {
            var typeRefProjection = type.GetElementType().projection as TypeReferenceProjection;

            return(typeRefProjection != null && typeRefProjection.Treatment == TypeReferenceTreatment.UseProjectionInfo);
        }