Rejects a call when a predicate returns an exception.
public sealed class GuardBehavior : IStuntBehavior
The predicate inspects the invocation and does not call the rest of the pipeline.
A null result continues the pipeline. Any other result fails the
call, and the rest of the pipeline does not run.
A synchronous member throws that exception on the caller thread. A member that returns or returns a faulted awaitable of the same type, so the caller observes the exception when it awaits. The target does not run.
The constructor is an invocation too. A behavior added before the stunt is materialized sees that call. A predicate that rejects it prevents the stunt from being constructed.
Add this behavior after the behaviors that should observe the rejection, and ahead of the behaviors that should see only accepted calls. The pipeline runs the first behavior outermost, so adding this one last places the check immediately before the target.
kind:method, kind:property, kind:ctor. Press Esc to clear.GuardBehavior(Func<IMethodInvocation, Exception?>)Initializes the behavior.AppliesTo(IMethodInvocation)Guards every invocation the pipeline dispatches.Execute(IMethodInvocation, ExecuteHandler)Runs the predicate. A null result calls next. An exception fails the invocation without calling next.