當前位置: 首頁>>代碼示例>>C#>>正文


C# MethodDefinition.AddGenericParameter方法代碼示例

本文整理匯總了C#中Mono.Cecil.MethodDefinition.AddGenericParameter方法的典型用法代碼示例。如果您正苦於以下問題:C# MethodDefinition.AddGenericParameter方法的具體用法?C# MethodDefinition.AddGenericParameter怎麽用?C# MethodDefinition.AddGenericParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.Cecil.MethodDefinition的用法示例。


在下文中一共展示了MethodDefinition.AddGenericParameter方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MatchGenericArguments

 /// <summary>
 /// Matches the generic parameters of <paramref name="newMethod">a target method</paramref>
 /// </summary>
 /// <param name="newMethod">The generic method that contains the generic type arguments.</param>
 /// <param name="typeArguments">The array of <see cref="Type"/> objects that describe the generic parameters for the current method.</param>
 private static void MatchGenericArguments(MethodDefinition newMethod, ICollection<Type> typeArguments)
 {
     foreach (Type argument in typeArguments)
     {
         newMethod.AddGenericParameter(argument);
     }
 }
開發者ID:svgorbunov,項目名稱:ScrollsModLoader,代碼行數:12,代碼來源:ProxyMethodBuilder.cs

示例2: DefineMethod

        /// <summary>
        /// Adds a new method to the <paramref name="typeDef">target type</paramref>.
        /// </summary>
        /// <param name="typeDef">The type that will hold the newly-created method.</param>
        /// <param name="attributes">The <see cref="MethodAttributes"/> parameter that describes the characteristics of the method.</param>
        /// <param name="methodName">The name to be given to the new method.</param>
        /// <param name="returnType">The method return type.</param>        
        /// <param name="parameterTypes">The list of argument types that will be used to define the method signature.</param>
        /// <param name="genericParameterTypes">The list of generic argument types that will be used to define the method signature.</param>
        /// <returns>A <see cref="MethodDefinition"/> instance that represents the newly-created method.</returns>
        public static MethodDefinition DefineMethod(this TypeDefinition typeDef, string methodName,
            MethodAttributes attributes, Type returnType, Type[] parameterTypes, Type[] genericParameterTypes)
        {
            var method = new MethodDefinition(methodName, attributes, null);

            typeDef.Methods.Add(method);

            //Match the generic parameter types
            foreach (var genericParameterType in genericParameterTypes)
            {
                method.AddGenericParameter(genericParameterType);
            }

            // Match the parameter types
            method.AddParameters(parameterTypes);

            // Match the return type
            method.SetReturnType(returnType);

            return method;
        }
開發者ID:slieser,項目名稱:LinFu,代碼行數:31,代碼來源:TypeDefinitionExtensions.cs

示例3: DefineMethod

        /// <summary>
        /// Adds a new method to the <paramref name="typeDef">target type</paramref>.
        /// </summary>
        /// <param name="typeDef">The type that will hold the newly-created method.</param>
        /// <param name="attributes">The <see cref="Mono.Cecil.MethodAttributes"/> parameter that describes the characteristics of the method.</param>
        /// <param name="methodName">The name to be given to the new method.</param>
        /// <param name="returnType">The method return type.</param>        
        /// <param name="parameterTypes">The list of argument types that will be used to define the method signature.</param>
        /// <param name="genericParameterTypes">The list of generic argument types that will be used to define the method signature.</param>
        /// <returns>A <see cref="MethodDefinition"/> instance that represents the newly-created method.</returns>
        public static MethodDefinition DefineMethod(this TypeDefinition typeDef, string methodName,
            Mono.Cecil.MethodAttributes attributes, System.Type returnType, System.Type[] parameterTypes, System.Type[] genericParameterTypes)
        {
            var method = new MethodDefinition(methodName, attributes, typeDef.Module.Import(typeof(object)));

            typeDef.Methods.Add(method);

            //Match the generic parameter types
            foreach (var genericParameterType in genericParameterTypes)
            {
                method.AddGenericParameter(genericParameterType);
            }

            // Match the parameter types
            method.AddParameters(parameterTypes);

            // Match the return type
            method.SetReturnType(returnType);

            return method;
        }
開發者ID:philiplaureano,項目名稱:Hiro,代碼行數:31,代碼來源:TypeDefinitionExtensions.cs


注:本文中的Mono.Cecil.MethodDefinition.AddGenericParameter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。