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

static private IsGenericInstance ( Type type ) : bool
type System.Type
Результат bool
Пример #1
0
        public FieldReference ImportField(FieldInfo field, ImportGenericContext context)
        {
            FieldReference fieldReference;
            TypeReference  typeReference = this.ImportType(field.DeclaringType, context);

            if (MetadataImporter.IsGenericInstance(field.DeclaringType))
            {
                field = MetadataImporter.ResolveFieldDefinition(field);
            }
            context.Push(typeReference);
            try
            {
                fieldReference = new FieldReference()
                {
                    Name          = field.Name,
                    DeclaringType = typeReference,
                    FieldType     = this.ImportType(field.FieldType, context)
                };
            }
            finally
            {
                context.Pop();
            }
            return(fieldReference);
        }
Пример #2
0
 private static bool IsTypeSpecification(Type type)
 {
     if (type.HasElementType || MetadataImporter.IsGenericInstance(type))
     {
         return(true);
     }
     return(type.IsGenericParameter);
 }
Пример #3
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);
        }