Mono.Cecil.MetadataImporter.ImportGenericParameter C# (CSharp) Méthode

ImportGenericParameter() static private méthode

static private ImportGenericParameter ( Type type, ImportGenericContext context ) : TypeReference
type System.Type
context ImportGenericContext
Résultat TypeReference
        static TypeReference ImportGenericParameter(Type type, ImportGenericContext context)
        {
            if (context.IsEmpty)
                throw new InvalidOperationException ();

            if (type.DeclaringMethod != null)
                return context.MethodParameter (type.DeclaringMethod.Name, type.GenericParameterPosition);

            if (type.DeclaringType != null)
                return  context.TypeParameter (NormalizedFullName (type.DeclaringType), type.GenericParameterPosition);

            throw new InvalidOperationException();
        }

Usage Example

Exemple #1
0
 private TypeReference ImportTypeSpecification(Type type, ImportGenericContext context)
 {
     if (type.IsByRef)
     {
         return(new ByReferenceType(this.ImportType(type.GetElementType(), context)));
     }
     if (type.IsPointer)
     {
         return(new PointerType(this.ImportType(type.GetElementType(), context)));
     }
     if (type.IsArray)
     {
         return(new ArrayType(this.ImportType(type.GetElementType(), context), type.GetArrayRank()));
     }
     if (type.IsGenericType)
     {
         return(this.ImportGenericInstance(type, context));
     }
     if (!type.IsGenericParameter)
     {
         throw new NotSupportedException(type.FullName);
     }
     return(MetadataImporter.ImportGenericParameter(type, context));
 }