Exemplo n.º 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]);
            }

            throw new NotImplementedException();
        }
		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 Resolve (assembly.MainModule, type);
			}

			ModuleDefinition module = type.Scope as ModuleDefinition;
			if (module != null)
				return Resolve (module, type);

			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 Resolve (netmodule, type);
			}

			throw new NotImplementedException ();
		}
Exemplo n.º 3
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(Resolve(assembly.MainModule, type));
            }

            ModuleDefinition module = type.Scope as ModuleDefinition;

            if (module != null)
            {
                return(Resolve(module, type));
            }

            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(Resolve(netmodule, type));
                    }
                }
            }

            throw new NotImplementedException();
        }
		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 = Resolve (reference);
				return assembly.MainModule.Types [type.FullName];
			}

			ModuleDefinition module = type.Scope as ModuleDefinition;
			if (module != null)
				return module.Types [type.FullName];

			throw new NotImplementedException ();
		}
 public override TypeReference GetOriginalType()
 {
     return(m_elementType.GetOriginalType());
 }
		bool IsVisibleFrom (TypeDefinition type, TypeReference reference)
		{
			if (reference == null)
				return true;

			if (reference is GenericParameter || reference.GetOriginalType () is GenericParameter)
				return true;

			TypeDefinition other = reference.Resolve ();
			if (other == null)
				return true;

			if (!AreInDifferentAssemblies (type, other))
				return true;

			if (IsPublic (other))
				return true;

			return false;
		}