我希望方面基于如下条件退出方法调用:
[AttributeUsage(AttributeTargets.Method)]
public class IgnoreIfInactiveAttribute : OnMethodBoundaryAspect
{
public override void OnEntry(MethodExecutionEventArgs eventArgs)
{
if (condition)
{
**// How can I make the method return here?**
}
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助非常感谢.
Mic*_*ann 10
好的,我自己想通了.这里的解决方案为每个人的利益:
[AttributeUsage(AttributeTargets.Method)]
public class IgnoreIfInactiveAttribute : OnMethodBoundaryAspect
{
public override void OnEntry(MethodExecutionEventArgs eventArgs)
{
if (condition)
{
eventArgs.FlowBehavior = FlowBehavior.Return;
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1094 次 |
| 最近记录: |