Example #1
0
        public TypeDefinition Resolve(TypeReference type)
        {
            type = type.GetOriginalType();

            if (type is TypeDefinition)
            {
                return((TypeDefinition)type);
            }

            AssemblyNameReference reference = type.Scope as AssemblyNameReference;

            if (reference != null)
            {
                AssemblyDefinition assembly = AssemblyResolver.Resolve(reference);
                if (assembly == null)
                {
                    return(null);
                }

                return(assembly.MainModule.Types [type.FullName]);
            }

            ModuleDefinition module = type.Scope as ModuleDefinition;

            if (module != null)
            {
                return(module.Types [type.FullName]);
            }

            ModuleReference mod_reference = type.Scope as ModuleReference;

            if (mod_reference != null)
            {
                foreach (ModuleDefinition netmodule in type.Module.Assembly.Modules)
                {
                    if (netmodule.Name == mod_reference.Name)
                    {
                        return(netmodule.Types [type.FullName]);
                    }
                }
            }

            throw new NotImplementedException();
        }
 public override TypeReference GetOriginalType()
 {
     return(m_elementType.GetOriginalType());
 }