AddBehavior(TStunt, Func) Method

Definition

Namespace Stunts
Assembly Stunts.dll

Adds a behavior factory to a stunt, so each pipeline seeded from these behaviors gets its own behavior instance instead of sharing one.

public static TStunt AddBehavior<TStunt>(this TStunt stunt, Func<IStuntBehavior> factory)
    where TStunt : IStunt

Type parameters

TStunt

Parameters

stunt
{TStunt}

The stunt to add the behavior factory to.

factory
Func<IStuntBehavior>

Function invoked to create the behavior instance.

Returns

{TStunt}

Remarks

If the stunt is not constructed yet, the factory is registered and invoked once per pipeline seeding (e.g. per StuntBuilder.Build call). If the stunt is already constructed, the factory is invoked immediately and the resulting instance is added to the live pipeline.