示例#1
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public override MethodInfo MakeGenericMethod(params Type[] methodInstantiation)
        {
            if (methodInstantiation == null)
            {
                throw new ArgumentNullException("methodInstantiation");
            }
            Contract.EndContractBlock();

            RuntimeType[] methodInstantionRuntimeType = new RuntimeType[methodInstantiation.Length];

            if (!IsGenericMethodDefinition)
            {
                throw new InvalidOperationException(
                          Environment.GetResourceString("Arg_NotGenericMethodDefinition", this));
            }

            for (int i = 0; i < methodInstantiation.Length; i++)
            {
                Type methodInstantiationElem = methodInstantiation[i];

                if (methodInstantiationElem == null)
                {
                    throw new ArgumentNullException();
                }

                RuntimeType rtMethodInstantiationElem = methodInstantiationElem as RuntimeType;

                if (rtMethodInstantiationElem == null)
                {
                    Type[] methodInstantiationCopy = new Type[methodInstantiation.Length];
                    for (int iCopy = 0; iCopy < methodInstantiation.Length; iCopy++)
                    {
                        methodInstantiationCopy[iCopy] = methodInstantiation[iCopy];
                    }
                    methodInstantiation = methodInstantiationCopy;
                    return(System.Reflection.Emit.MethodBuilderInstantiation.MakeGenericMethod(this, methodInstantiation));
                }

                methodInstantionRuntimeType[i] = rtMethodInstantiationElem;
            }

            RuntimeType[] genericParameters = GetGenericArgumentsInternal();

            RuntimeType.SanityCheckGenericArguments(methodInstantionRuntimeType, genericParameters);

            MethodInfo ret = null;

            try
            {
                ret = RuntimeType.GetMethodBase(ReflectedTypeInternal,
                                                RuntimeMethodHandle.GetStubIfNeeded(new RuntimeMethodHandleInternal(this.m_handle), m_declaringType, methodInstantionRuntimeType)) as MethodInfo;
            }
            catch (VerificationException e)
            {
                RuntimeType.ValidateGenericArguments(this, methodInstantionRuntimeType, e);
                throw;
            }

            return(ret);
        }
示例#2
0
        public override MethodInfo MakeGenericMethod(params Type[] methodInstantiation)
        {
            if (methodInstantiation == null)
            {
                throw new ArgumentNullException("methodInstantiation");
            }
            RuntimeType[] array = new RuntimeType[methodInstantiation.Length];
            if (!this.IsGenericMethodDefinition)
            {
                throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericMethodDefinition", new object[]
                {
                    this
                }));
            }
            for (int i = 0; i < methodInstantiation.Length; i++)
            {
                Type type = methodInstantiation[i];
                if (type == null)
                {
                    throw new ArgumentNullException();
                }
                RuntimeType runtimeType = type as RuntimeType;
                if (runtimeType == null)
                {
                    Type[] array2 = new Type[methodInstantiation.Length];
                    for (int j = 0; j < methodInstantiation.Length; j++)
                    {
                        array2[j] = methodInstantiation[j];
                    }
                    methodInstantiation = array2;
                    return(MethodBuilderInstantiation.MakeGenericMethod(this, methodInstantiation));
                }
                array[i] = runtimeType;
            }
            RuntimeType[] genericArgumentsInternal = this.GetGenericArgumentsInternal();
            RuntimeType.SanityCheckGenericArguments(array, genericArgumentsInternal);
            MethodInfo result = null;

            try
            {
                result = (RuntimeType.GetMethodBase(this.ReflectedTypeInternal, RuntimeMethodHandle.GetStubIfNeeded(new RuntimeMethodHandleInternal(this.m_handle), this.m_declaringType, array)) as MethodInfo);
            }
            catch (VerificationException e)
            {
                RuntimeType.ValidateGenericArguments(this, array, e);
                throw;
            }
            return(result);
        }
示例#3
0
 public override MethodInfo MakeGenericMethod(params Type[] methodInstantiation)
 {
     if (methodInstantiation == null)
     {
         throw new ArgumentNullException("methodInstantiation");
     }
     RuntimeType[] runtimeTypeArray = new RuntimeType[methodInstantiation.Length];
     if (!this.IsGenericMethodDefinition)
     {
         throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericMethodDefinition", (object)this));
     }
     for (int index1 = 0; index1 < methodInstantiation.Length; ++index1)
     {
         Type type = methodInstantiation[index1];
         // ISSUE: variable of the null type
         __Null local = null;
         if (type == (Type)local)
         {
             throw new ArgumentNullException();
         }
         RuntimeType runtimeType = type as RuntimeType;
         if (runtimeType == (RuntimeType)null)
         {
             Type[] typeArray = new Type[methodInstantiation.Length];
             for (int index2 = 0; index2 < methodInstantiation.Length; ++index2)
             {
                 typeArray[index2] = methodInstantiation[index2];
             }
             methodInstantiation = typeArray;
             return(MethodBuilderInstantiation.MakeGenericMethod((MethodInfo)this, methodInstantiation));
         }
         runtimeTypeArray[index1] = runtimeType;
     }
     RuntimeType[] argumentsInternal = this.GetGenericArgumentsInternal();
     RuntimeType.SanityCheckGenericArguments(runtimeTypeArray, argumentsInternal);
     try
     {
         return(RuntimeType.GetMethodBase(this.ReflectedTypeInternal, RuntimeMethodHandle.GetStubIfNeeded(new RuntimeMethodHandleInternal(this.m_handle), this.m_declaringType, runtimeTypeArray)) as MethodInfo);
     }
     catch (VerificationException ex)
     {
         RuntimeType.ValidateGenericArguments((MemberInfo)this, runtimeTypeArray, (Exception)ex);
         throw;
     }
 }