当前位置: 首页>>代码示例>>C#>>正文


C# MethodBase.Parameters方法代码示例

本文整理汇总了C#中System.Reflection.MethodBase.Parameters方法的典型用法代码示例。如果您正苦于以下问题:C# MethodBase.Parameters方法的具体用法?C# MethodBase.Parameters怎么用?C# MethodBase.Parameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.MethodBase的用法示例。


在下文中一共展示了MethodBase.Parameters方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MethodMap

 public MethodMap(MethodBase method, string[] paramNames, Type[] paramTypes, object[] sampleParamValues, bool mustUseAllParameters)
 {
     type = method.DeclaringType;
     this.method = method;
     this.paramNames = paramNames;
     this.paramTypes = paramTypes;
     requiredParameterCount = method.Parameters().Count;
     this.mustUseAllParameters = mustUseAllParameters;
     parameters = method.Parameters();
     InitializeBitArrays(Math.Max(parameters.Count, paramNames.Length));
     InitializeMethodMap(sampleParamValues);
 }
开发者ID:devworker55,项目名称:Mammatus,代码行数:12,代码来源:MethodMap.cs

示例2: GetMethodSignature

        /// <summary>
        /// Gets the method signature in string format.
        /// </summary>
        /// <param name="method">The method signature.</param>
        /// <returns></returns>
        private string GetMethodSignature(MethodBase method)
        {
            var parameters = from m in method.Parameters()
                             select m.ParameterType.ToString();

            return string.Format("{0}+{1}", TargetAttribute.FullName, MethodSignatureFormatter.Create(method, parameters.ToArray()));
        }
开发者ID:grava,项目名称:Snap,代码行数:12,代码来源:MethodInterceptor.cs

示例3: Create

        /// <summary>
        /// Gets the formatting strings representing a method.
        /// </summary>
        /// <param name="method">A <see cref="MethodBase"/>.</param>
        /// <param name="methodParameters">The method parameters.</param>
        /// <returns></returns>
        public static string Create(MethodBase method, object[] methodParameters)
        {
            bool methodIsGeneric;

            var stringBuilder = new StringBuilder();

            var typeFormat = GetTypeFormatString(method.DeclaringType);
            var typeIsGeneric = method.DeclaringType.IsGenericTypeDefinition;

            // Build the format string for the method name.
            stringBuilder.Length = 0;
            stringBuilder.Append("::");
            stringBuilder.Append(method.Name);

            if (method.IsGenericMethodDefinition)
            {
                methodIsGeneric = true;
                stringBuilder.Append("<");

                for (var i = 0; i < method.GetGenericArguments().Length; i++)
                {
                    if (i > 0)
                    {
                        stringBuilder.Append(", ");
                    }

                    stringBuilder.AppendFormat("{{{0}}}", i);
                }

                stringBuilder.Append(">");
            }
            else
            {
                methodIsGeneric = false;
            }

            var methodFormat = stringBuilder.ToString();

            // Build the format string for parameters.
            stringBuilder.Length = 0;
            var parameters = method.Parameters();
            stringBuilder.Append("(");

            for (var i = 0; i < parameters.Count; i++)
            {
                if (i > 0)
                {
                    stringBuilder.Append(", ");
                }

                stringBuilder.Append("{{{");
                stringBuilder.Append(i);
                stringBuilder.Append("}}}");
            }

            stringBuilder.Append(")");

            var parameterFormat = stringBuilder.ToString();

            var signature = new MethodSignature
            {
                MethodFormat = methodFormat,
                MethodIsGeneric = methodIsGeneric,
                ParameterFormat = parameterFormat,
                TypeFormat = typeFormat,
                TypeIsGeneric = typeIsGeneric
            };

            return Format(signature, method, methodParameters);
        }
开发者ID:nickspoons,项目名称:Snap,代码行数:76,代码来源:MethodSignatureFormatter.cs


注:本文中的System.Reflection.MethodBase.Parameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。