本文整理汇总了C#中IInvocation.ThrowIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# IInvocation.ThrowIfNull方法的具体用法?C# IInvocation.ThrowIfNull怎么用?C# IInvocation.ThrowIfNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IInvocation
的用法示例。
在下文中一共展示了IInvocation.ThrowIfNull方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Intercept
public virtual void Intercept(IInvocation invocation)
{
invocation.ThrowIfNull("invocation", "Parameter cannot be null.");
if (LogAggregator == null)
return;
StringBuilder sb = new StringBuilder();
sb.Append("Action: before method executes, ");
sb.Append(string.Format("Method name {0}{1}", invocation.MethodInvocationTarget.Name, Environment.NewLine));
if (invocation.Arguments != null && invocation.Arguments.Length > 0)
{
var parameters = invocation.MethodInvocationTarget.GetParameters();
for (int i = 0; i < parameters.Length; i++)
{
sb.AppendLine(string.Format("Parameter name: {0}, value: {1}", parameters[i].Name, invocation.Arguments[i]));
}
}
else
sb.AppendLine("Method is parameterless.");
if (invocation.ReturnValueType != typeof(void))
sb.AppendLine(string.Format("Return type is {0}", invocation.ReturnValue));
LogAggregator.DoLog(Logging.LogSeverity.Info, sb.ToString(), null);
sb.Clear();
}
示例2: Intercept
public virtual void Intercept(IInvocation invocation)
{
invocation.ThrowIfNull("invocation", "Parameter cannot be null.");
ProceesException(invocation);
}