示例#1
0
 public virtual TypeReference ImportReference(Type type, IGenericParameterProvider context)
 {
     Mixin.CheckType(type);
     return(ImportType(
                type,
                ImportGenericContext.For(context),
                context != null ? ImportGenericKind.Open : ImportGenericKind.Definition));
 }
示例#2
0
 public MethodReference(string name, TypeReference returnType)
     : base(name)
 {
     Mixin.CheckType(returnType, Mixin.Argument.returnType);
     return_type            = new MethodReturnType(this);
     return_type.ReturnType = returnType;
     base.token             = new MetadataToken(TokenType.MemberRef);
 }
示例#3
0
        public FieldReference(string name, TypeReference fieldType)
            : base(name)
        {
            Mixin.CheckType(fieldType, Mixin.Argument.fieldType);

            this.field_type = fieldType;
            this.token      = new MetadataToken(TokenType.MemberRef);
        }
示例#4
0
 public TypeReference ImportReference(TypeReference type, IGenericParameterProvider context)
 {
     Mixin.CheckType(type);
     if (type.Module == this)
     {
         return(type);
     }
     CheckContext(context, this);
     return(MetadataImporter.ImportReference(type, context));
 }
示例#5
0
 public OptionalModifierType(TypeReference modifierType, TypeReference type)
     : base(type)
 {
     if (modifierType == null)
     {
         throw new ArgumentNullException(9.ToString());
     }
     Mixin.CheckType(type);
     modifier_type = modifierType;
     base.etype    = Mono.Cecil.Metadata.ElementType.CModOpt;
 }
示例#6
0
 public OptionalModifierType(TypeReference modifierType, TypeReference type)
     : base(type)
 {
     if (modifierType == null)
     {
         throw new ArgumentNullException(Mixin.Argument.modifierType.ToString());
     }
     Mixin.CheckType(type);
     this.modifier_type = modifierType;
     this.etype         = MD.ElementType.CModOpt;
 }
示例#7
0
 public ArrayType(TypeReference type, int rank) : this(type)
 {
     Mixin.CheckType(type);
     if (rank != 1)
     {
         this.dimensions = new Collection <ArrayDimension>(rank);
         for (int i = 0; i < rank; i++)
         {
             ArrayDimension item = new ArrayDimension();
             this.dimensions.Add(item);
         }
         base.etype = ElementType.Array;
     }
 }
 public ArrayType(TypeReference type, int rank) : this(type)
 {
     Mixin.CheckType(type);
     if (rank == 1)
     {
         return;
     }
     this.dimensions = new Collection <ArrayDimension>(rank);
     for (int i = 0; i < rank; i++)
     {
         this.dimensions.Add(new ArrayDimension());
     }
     this.etype = Mono.Cecil.Metadata.ElementType.Array;
 }
示例#9
0
 public ArrayType(TypeReference type, int rank)
     : this(type)
 {
     Mixin.CheckType(type);
     if (rank != 1)
     {
         dimensions = new Collection <ArrayDimension>(rank);
         for (int i = 0; i < rank; i++)
         {
             dimensions.Add(default(ArrayDimension));
         }
         base.etype = Mono.Cecil.Metadata.ElementType.Array;
     }
 }
示例#10
0
        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:
                if (type.Module.Assembly == null)
                {
                    return(null);
                }

                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();
        }
示例#11
0
        public virtual TypeDefinition Resolve(TypeReference type)
        {
            Mixin.CheckType(type);
            type = type.GetElementType();
            IMetadataScope scope = type.Scope;

            if (scope == null)
            {
                return(null);
            }
            switch (scope.MetadataScopeType)
            {
            case MetadataScopeType.AssemblyNameReference:
            {
                AssemblyDefinition assemblyDefinition = assembly_resolver.Resolve((AssemblyNameReference)scope);
                if (assemblyDefinition == null)
                {
                    return(null);
                }
                return(GetType(assemblyDefinition.MainModule, type));
            }

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

            case MetadataScopeType.ModuleReference:
            {
                Collection <ModuleDefinition> modules = type.Module.Assembly.Modules;
                ModuleReference moduleReference       = (ModuleReference)scope;
                for (int i = 0; i < modules.Count; i++)
                {
                    ModuleDefinition moduleDefinition = modules[i];
                    if (moduleDefinition.Name == moduleReference.Name)
                    {
                        return(GetType(moduleDefinition, type));
                    }
                }
                break;
            }
            }
            throw new NotSupportedException();
        }
示例#12
0
 public PointerType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     this.etype = MD.ElementType.Ptr;
 }
示例#13
0
 public PinnedType(TypeReference type) : base(type)
 {
     Mixin.CheckType(type);
     base.etype = ElementType.Pinned;
 }
示例#14
0
 public TypeReference ImportReference(Type type, IGenericParameterProvider context)
 {
     Mixin.CheckType(type);
     CheckContext(context, this);
     return(ReflectionImporter.ImportReference(type, context));
 }
示例#15
0
 public ByReferenceType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     base.etype = Mono.Cecil.Metadata.ElementType.ByRef;
 }
示例#16
0
 public InterfaceImplementation(TypeReference interfaceType)
 {
     Mixin.CheckType(interfaceType, Mixin.Argument.interfaceType);
     interface_type = interfaceType;
     token          = new MetadataToken(TokenType.InterfaceImpl);
 }
 public SentinelType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     this.etype = MD.ElementType.Sentinel;
 }
示例#18
0
 internal PropertyReference(string name, TypeReference propertyType)
     : base(name)
 {
     Mixin.CheckType(propertyType, Mixin.Argument.propertyType);
     property_type = propertyType;
 }
 public SentinelType(TypeReference type) : base(type)
 {
     Mixin.CheckType(type);
     this.etype = Mono.Cecil.Metadata.ElementType.Sentinel;
 }
示例#20
0
 public ByReferenceType(TypeReference type) : base(type)
 {
     Mixin.CheckType(type);
     base.etype = ElementType.ByRef;
 }
示例#21
0
 protected EventReference(string name, TypeReference eventType)
     : base(name)
 {
     Mixin.CheckType(eventType, Mixin.Argument.eventType);
     event_type = eventType;
 }
示例#22
0
 public PinnedType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     this.etype = MD.ElementType.Pinned;
 }
示例#23
0
 public virtual TypeReference ImportReference(TypeReference type, IGenericParameterProvider context)
 {
     Mixin.CheckType(type);
     return(ImportType(type, ImportGenericContext.For(context)));
 }
 public PointerType(TypeReference type) : base(type)
 {
     Mixin.CheckType(type);
     this.etype = Mono.Cecil.Metadata.ElementType.Ptr;
 }
示例#25
0
 public ArrayType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     this.etype = MD.ElementType.Array;
 }
 public PinnedType(TypeReference type) : base(type)
 {
     Mixin.CheckType(type);
     this.etype = Mono.Cecil.Metadata.ElementType.Pinned;
 }
示例#27
0
 public ByReferenceType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     this.etype = MD.ElementType.ByRef;
 }
示例#28
0
 public ArrayType(TypeReference type) : base(type)
 {
     Mixin.CheckType(type);
     base.etype = ElementType.Array;
 }
 public CustomAttributeArgument(TypeReference type, object value)
 {
     Mixin.CheckType(type);
     this.type  = type;
     this.value = value;
 }
示例#30
0
 public ArrayType(TypeReference type) : base(type)
 {
     Mixin.CheckType(type);
     this.etype = Mono.Cecil.Metadata.ElementType.Array;
 }