ImportGenericParameters() статический приватный Метод

static private ImportGenericParameters ( IGenericParameterProvider imported, IGenericParameterProvider original ) : void
imported IGenericParameterProvider
original IGenericParameterProvider
Результат void
Пример #1
0
        public TypeReference ImportType(Type type, ImportGenericContext context, ImportGenericKind import_kind)
        {
            if (MetadataImporter.IsTypeSpecification(type) || MetadataImporter.ImportOpenGenericType(type, import_kind))
            {
                return(this.ImportTypeSpecification(type, context));
            }
            TypeReference typeReference = new TypeReference(string.Empty, type.Name, this.module, this.ImportScope(type.Assembly), type.IsValueType)
            {
                etype = MetadataImporter.ImportElementType(type)
            };

            if (!MetadataImporter.IsNestedType(type))
            {
                typeReference.Namespace = type.Namespace ?? string.Empty;
            }
            else
            {
                typeReference.DeclaringType = this.ImportType(type.DeclaringType, context, import_kind);
            }
            if (type.IsGenericType)
            {
                MetadataImporter.ImportGenericParameters(typeReference, type.GetGenericArguments());
            }
            return(typeReference);
        }
Пример #2
0
        public MethodReference ImportMethod(MethodBase method, ImportGenericContext context, ImportGenericKind import_kind)
        {
            MethodReference methodReference;

            if (MetadataImporter.IsMethodSpecification(method) || MetadataImporter.ImportOpenGenericMethod(method, import_kind))
            {
                return(this.ImportMethodSpecification(method, context));
            }
            TypeReference typeReference = this.ImportType(method.DeclaringType, context);

            if (MetadataImporter.IsGenericInstance(method.DeclaringType))
            {
                method = method.Module.ResolveMethod(method.MetadataToken);
            }
            MethodReference methodReference1 = new MethodReference()
            {
                Name          = method.Name,
                HasThis       = MetadataImporter.HasCallingConvention(method, CallingConventions.HasThis),
                ExplicitThis  = MetadataImporter.HasCallingConvention(method, CallingConventions.ExplicitThis),
                DeclaringType = this.ImportType(method.DeclaringType, context, ImportGenericKind.Definition)
            };

            if (MetadataImporter.HasCallingConvention(method, CallingConventions.VarArgs))
            {
                MethodReference callingConvention = methodReference1;
                callingConvention.CallingConvention = callingConvention.CallingConvention & MethodCallingConvention.VarArg;
            }
            if (method.IsGenericMethod)
            {
                MetadataImporter.ImportGenericParameters(methodReference1, method.GetGenericArguments());
            }
            context.Push(methodReference1);
            try
            {
                MethodInfo methodInfo = method as MethodInfo;
                methodReference1.ReturnType = (methodInfo != null ? this.ImportType(methodInfo.ReturnType, context) : this.ImportType(typeof(void), new ImportGenericContext()));
                ParameterInfo[] parameters = method.GetParameters();
                Collection <ParameterDefinition> parameterDefinitions = methodReference1.Parameters;
                for (int i = 0; i < (int)parameters.Length; i++)
                {
                    parameterDefinitions.Add(new ParameterDefinition(this.ImportType(parameters[i].ParameterType, context)));
                }
                methodReference1.DeclaringType = typeReference;
                methodReference = methodReference1;
            }
            finally
            {
                context.Pop();
            }
            return(methodReference);
        }
Пример #3
0
        public MethodReference ImportMethod(MethodReference method, ImportGenericContext context)
        {
            MethodReference methodReference;

            if (method.IsGenericInstance)
            {
                return(this.ImportMethodSpecification(method, context));
            }
            TypeReference   typeReference    = this.ImportType(method.DeclaringType, context);
            MethodReference methodReference1 = new MethodReference()
            {
                Name              = method.Name,
                HasThis           = method.HasThis,
                ExplicitThis      = method.ExplicitThis,
                DeclaringType     = typeReference,
                CallingConvention = method.CallingConvention
            };

            if (method.HasGenericParameters)
            {
                MetadataImporter.ImportGenericParameters(methodReference1, method);
            }
            context.Push(methodReference1);
            try
            {
                methodReference1.ReturnType = this.ImportType(method.ReturnType, context);
                if (method.HasParameters)
                {
                    Collection <ParameterDefinition> parameters           = methodReference1.Parameters;
                    Collection <ParameterDefinition> parameterDefinitions = method.Parameters;
                    for (int i = 0; i < parameterDefinitions.Count; i++)
                    {
                        parameters.Add(new ParameterDefinition(this.ImportType(parameterDefinitions[i].ParameterType, context)));
                    }
                    methodReference = methodReference1;
                }
                else
                {
                    methodReference = methodReference1;
                }
            }
            finally
            {
                context.Pop();
            }
            return(methodReference);
        }
Пример #4
0
        public TypeReference ImportType(TypeReference type, ImportGenericContext context)
        {
            if (type.IsTypeSpecification())
            {
                return(this.ImportTypeSpecification(type, context));
            }
            TypeReference typeReference = new TypeReference(type.Namespace, type.Name, this.module, this.ImportScope(type.Scope), type.IsValueType);

            MetadataSystem.TryProcessPrimitiveTypeReference(typeReference);
            if (type.IsNested)
            {
                typeReference.DeclaringType = this.ImportType(type.DeclaringType, context);
            }
            if (type.HasGenericParameters)
            {
                MetadataImporter.ImportGenericParameters(typeReference, type);
            }
            return(typeReference);
        }