本文整理汇总了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);
}
示例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()));
}
示例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);
}