コード例 #1
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);
        }
コード例 #2
0
        public override MethodInfo MakeGenericMethod(params Type[] methodInstantiation)
        {
            if (methodInstantiation == null)
            {
                throw new ArgumentNullException("methodInstantiation");
            }
            Type[] typeArray = new Type[methodInstantiation.Length];
            for (int i = 0; i < methodInstantiation.Length; i++)
            {
                typeArray[i] = methodInstantiation[i];
            }
            methodInstantiation = typeArray;
            if (!this.IsGenericMethodDefinition)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Arg_NotGenericMethodDefinition"), new object[] { this }));
            }
            for (int j = 0; j < methodInstantiation.Length; j++)
            {
                if (methodInstantiation[j] == null)
                {
                    throw new ArgumentNullException();
                }
                if (!(methodInstantiation[j] is RuntimeType))
                {
                    return(MethodBuilderInstantiation.MakeGenericMethod(this, methodInstantiation));
                }
            }
            Type[] genericArguments = this.GetGenericArguments();
            RuntimeType.SanityCheckGenericArguments(methodInstantiation, genericArguments);
            RuntimeTypeHandle[] handleArray = new RuntimeTypeHandle[methodInstantiation.Length];
            for (int k = 0; k < methodInstantiation.Length; k++)
            {
                handleArray[k] = methodInstantiation[k].GetTypeHandleInternal();
            }
            MethodInfo methodBase = null;

            try
            {
                methodBase = RuntimeType.GetMethodBase(this.m_reflectedTypeCache.RuntimeTypeHandle, this.m_handle.GetInstantiatingStub(this.m_declaringType.GetTypeHandleInternal(), handleArray)) as MethodInfo;
            }
            catch (VerificationException exception)
            {
                RuntimeType.ValidateGenericArguments(this, methodInstantiation, exception);
                throw exception;
            }
            return(methodBase);
        }
コード例 #3
0
ファイル: 1methodinfo.cs プロジェクト: wwkkww1983/ZJCredit
 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;
     }
 }