5

次のような条件に基づいて、アスペクトがメソッド呼び出しを終了するようにしたいと思います。

    [AttributeUsage(AttributeTargets.Method)]
    public class IgnoreIfInactiveAttribute : OnMethodBoundaryAspect
    {
        public override void OnEntry(MethodExecutionEventArgs eventArgs)
        {
             if (condition)
            {
                **// How can I make the method return here?**
            }
        }
    }

どんな助けでも大歓迎です。

4

1 に答える 1

10

わかりました、私はそれを自分で理解しました。ここにすべての人のための解決策があります:

    [AttributeUsage(AttributeTargets.Method)] 
    public class IgnoreIfInactiveAttribute : OnMethodBoundaryAspect 
    { 
        public override void OnEntry(MethodExecutionEventArgs eventArgs) 
        { 
             if (condition) 
            { 
                eventArgs.FlowBehavior = FlowBehavior.Return;
            } 
        } 
    } 
于 2010-03-13T08:55:34.730 に答える