Table of Contents

Class ActionDecorator<TIn>

Namespace
PatternKit.Structural.Decorator
Assembly
PatternKit.Core.dll

Fluent, allocation-light action decorator that wraps a component and applies layered enhancements for side effects (void-returning operations). Build once, then call Execute(in TIn) to run the component through the decorator pipeline.

public sealed class ActionDecorator<TIn>

Type Parameters

TIn

Input type passed to the component.

Inheritance
ActionDecorator<TIn>
Inherited Members

Examples

var decorator = ActionDecorator<string>.Create(msg => Console.WriteLine(msg))
    .Before(msg => $"[{DateTime.Now}] {msg}")  // Add timestamp
    .After(msg => Console.WriteLine("---"))    // Add separator after
    .Build();

decorator.Execute("Hello"); // Prints timestamped message and separator

Remarks

Mental model: A base component (action) is wrapped by zero or more decorators. Each decorator can:

Immutability: After Build(), the decorator chain is immutable and safe for concurrent reuse.

Methods

Create(Component)

Creates a new builder for constructing a decorated action.

public static ActionDecorator<TIn>.Builder Create(ActionDecorator<TIn>.Component component)

Parameters

component ActionDecorator<TIn>.Component

Returns

ActionDecorator<TIn>.Builder

Execute(in TIn)

Executes the decorated component with the given input.

public void Execute(in TIn input)

Parameters

input TIn