本文整理汇总了C#中System.Reflection.MethodInfo.IsVoid方法的典型用法代码示例。如果您正苦于以下问题:C# MethodInfo.IsVoid方法的具体用法?C# MethodInfo.IsVoid怎么用?C# MethodInfo.IsVoid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MethodInfo
的用法示例。
在下文中一共展示了MethodInfo.IsVoid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDelegate
protected string GetDelegate (MethodInfo method)
{
var parameters = method.GetParameters();
if (parameters.Length == 0)
return method.IsVoid () ? "Action" : "Func<" + GetTypeName(method.ReturnType) + ">";
if (method.HasOutOrRef ()) {
// In this case the template will generate a custom delegate with the
// method name and all parameter types, to ensure uniqueness, i.e. FooInt32BooleanString
return method.Name + string.Join ("", parameters.Select (x => x.ParameterType.Name.TrimEnd ('&')));
} else {
var typeParams = string.Join(", ", parameters.Select(x => GetTypeName(x.ParameterType)));
return method.IsVoid () ?
"Action<" + typeParams + ">" :
"Func<" + typeParams + ", " + GetTypeName(method.ReturnType) + ">";
}
}
示例2: CanBeConfigured
/// <summary>
/// Determines whether a method can be mocked.
/// </summary>
/// <param name="method">The candidate method.</param>
/// <returns>Whether <paramref name="method"/> can be configured.</returns>
private static bool CanBeConfigured(MethodInfo method)
{
return method.IsOverridable() &&
!method.IsGenericMethod &&
!method.HasRefParameters() &&
(!method.IsVoid() || method.HasOutParameters());
}