GuardBehavior Class

Definition

Rejects a call when a predicate returns an exception.

public sealed class GuardBehavior : IStuntBehavior

Remarks

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.

Tip: use kind:method, kind:property, kind:ctor. Press Esc to clear.

Constructors (1)

Methods (2)