Exemplo n.º 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));
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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));
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 12
0
 public PointerType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     this.etype = MD.ElementType.Ptr;
 }
Exemplo n.º 13
0
 public PinnedType(TypeReference type) : base(type)
 {
     Mixin.CheckType(type);
     base.etype = ElementType.Pinned;
 }
Exemplo n.º 14
0
 public TypeReference ImportReference(Type type, IGenericParameterProvider context)
 {
     Mixin.CheckType(type);
     CheckContext(context, this);
     return(ReflectionImporter.ImportReference(type, context));
 }
Exemplo n.º 15
0
 public ByReferenceType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     base.etype = Mono.Cecil.Metadata.ElementType.ByRef;
 }
Exemplo n.º 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;
 }
Exemplo n.º 18
0
 internal PropertyReference(string name, TypeReference propertyType)
     : base(name)
 {
     Mixin.CheckType(propertyType, Mixin.Argument.propertyType);
     property_type = propertyType;
 }
Exemplo n.º 19
0
 public SentinelType(TypeReference type) : base(type)
 {
     Mixin.CheckType(type);
     this.etype = Mono.Cecil.Metadata.ElementType.Sentinel;
 }
Exemplo n.º 20
0
 public ByReferenceType(TypeReference type) : base(type)
 {
     Mixin.CheckType(type);
     base.etype = ElementType.ByRef;
 }
Exemplo n.º 21
0
 protected EventReference(string name, TypeReference eventType)
     : base(name)
 {
     Mixin.CheckType(eventType, Mixin.Argument.eventType);
     event_type = eventType;
 }
Exemplo n.º 22
0
 public PinnedType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     this.etype = MD.ElementType.Pinned;
 }
Exemplo n.º 23
0
 public virtual TypeReference ImportReference(TypeReference type, IGenericParameterProvider context)
 {
     Mixin.CheckType(type);
     return(ImportType(type, ImportGenericContext.For(context)));
 }
Exemplo n.º 24
0
 public PointerType(TypeReference type) : base(type)
 {
     Mixin.CheckType(type);
     this.etype = Mono.Cecil.Metadata.ElementType.Ptr;
 }
Exemplo n.º 25
0
 public ArrayType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     this.etype = MD.ElementType.Array;
 }
Exemplo n.º 26
0
 public PinnedType(TypeReference type) : base(type)
 {
     Mixin.CheckType(type);
     this.etype = Mono.Cecil.Metadata.ElementType.Pinned;
 }
Exemplo n.º 27
0
 public ByReferenceType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     this.etype = MD.ElementType.ByRef;
 }
Exemplo n.º 28
0
 public ArrayType(TypeReference type) : base(type)
 {
     Mixin.CheckType(type);
     base.etype = ElementType.Array;
 }
Exemplo n.º 29
0
 public CustomAttributeArgument(TypeReference type, object value)
 {
     Mixin.CheckType(type);
     this.type  = type;
     this.value = value;
 }
Exemplo n.º 30
0
 public ArrayType(TypeReference type) : base(type)
 {
     Mixin.CheckType(type);
     this.etype = Mono.Cecil.Metadata.ElementType.Array;
 }