Mono.Cecil.ImportGenericContext.GenericTypeFor C# (CSharp) Method

GenericTypeFor() static private method

static private GenericTypeFor ( IGenericParameterProvider context ) : TypeReference
context IGenericParameterProvider
return TypeReference
        static TypeReference GenericTypeFor(IGenericParameterProvider context)
        {
            var type = context as TypeReference;
            if (type != null)
                return type.GetElementType ();

            var method = context as MethodReference;
            if (method != null)
                return method.DeclaringType.GetElementType ();

            throw new InvalidOperationException ();
        }

Usage Example

Esempio n. 1
0
 public TypeReference TypeParameter(string type, int position)
 {
     for (int i = this.stack.Count - 1; i >= 0; i--)
     {
         TypeReference typeReference = ImportGenericContext.GenericTypeFor(this.stack[i]);
         if (typeReference.FullName == type)
         {
             return(typeReference.GenericParameters[position]);
         }
     }
     throw new InvalidOperationException();
 }