本文整理汇总了C#中System.Reflection.MethodInfo.Parameters方法的典型用法代码示例。如果您正苦于以下问题:C# MethodInfo.Parameters方法的具体用法?C# MethodInfo.Parameters怎么用?C# MethodInfo.Parameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MethodInfo
的用法示例。
在下文中一共展示了MethodInfo.Parameters方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertParams
private static object[] ConvertParams(IRpcMail mail, MethodInfo func)
{
var p = func.Parameters();
var args = new object[p.Count];
args[0] = mail;
for (int i = 0; i < mail.Message.Args.Length; i++)
args[i + 1] = ConvertEx.Convert(mail.Message.Args[i], p[i + 1].ParameterType);
return args;
}
示例2: IsSuperfluous
private static bool IsSuperfluous( MethodInfo method, IEnumerable<MethodInfo> methods )
{
IList<ParameterInfo> parameters = method.Parameters();
bool lastIsParams = HasParamsParameter( parameters );
if( lastIsParams )
{
return false;
}
return methods.Where( m => method.IsGenericMethod
? m.IsGenericMethod &&
method.GetGenericArguments().SequenceEqual( m.GetGenericArguments() )
: !m.IsGenericMethod )
.Select( m => m.Parameters() )
.Where( ps => parameters.Count == ps.Count - 1 && HasParamsParameter( ps ) )
.Any(
ps =>
parameters.Select( p => p.ParameterType ).SequenceEqual( ps.Take( parameters.Count ).Select( p => p.ParameterType ) ) );
}
示例3: Method
public Method(MethodInfo mi)
{
HttpMethod = "get";
Name = mi.Name;
ParamInfos = mi.Parameters().Select(x => new ParamInfo(x)).ToArray();
ReturnType = mi.ReturnType;
var attribs = mi.GetCustomAttributes(false).Cast<Attribute>().ToArray();
var swaggerAttrs =
attribs.Where(
x => x.GetType().FullName == "Swashbuckle.Swagger.Annotations.SwaggerResponseAttribute")
.ToList();
var postAttr=
attribs.Where(
x => x.GetType().FullName.EndsWith("HttpPostAttribute"))
.ToList();
var ok = swaggerAttrs.SingleOrDefault(x => (int)x.GetType().Property("StatusCode").GetValue(x) == (int)HttpStatusCode.OK);
if (ok != null)
{
ReturnType = (Type)ok.GetType().Property("Type").GetValue(ok);
}
var isPost = postAttr.Any();
if (isPost)
{
HttpMethod = "post";
}
}