Activate

Stores the train input (and optional extra objects) into Memory. Typically the first method called in RunInternal. After activation, the input is available to subsequent junctions via Memory's type-based lookup.

Signature

// Train<TInput, TReturn>
public Monad<TInput, TReturn> Activate(TInput input, params object[] otherInputs)
 
// ServiceTrain<TIn, TOut> — overrides to inject ServiceProvider for junction DI
public new Monad<TIn, TOut> Activate(TIn input, params object[] otherInputs)

Parameters

ParameterTypeRequiredDescription
inputTInputYesThe primary train input. Stored in Memory by its concrete type and all its interfaces.
otherInputsparams object[]NoAdditional objects to store in Memory. Each is stored by its concrete type and interfaces.

Returns

Monad<TInput, TReturn> — the train instance, for fluent chaining.

Examples

Basic Activation

protected override async Task<Either<Exception, OrderResult>> RunInternal(OrderInput input)
{
    return Activate(input)
        .Chain<ValidateOrder>()
        .Chain<ProcessPayment>()
        .Resolve();
}

With Extra Inputs

protected override async Task<Either<Exception, OrderResult>> RunInternal(OrderInput input)
{
    return Activate(input, _configService, _logger)
        .Chain<ValidateOrder>()
        .Resolve();
}

Behavior Details

Simple Types

The object is stored by its concrete type and all its interfaces. For example, if input is of type OrderInput which implements IOrderInput, it's stored under both typeof(OrderInput) and typeof(IOrderInput).

Tuple Types

Each element of the tuple is extracted and stored individually. For example, (string, int) stores the string and int as separate Memory entries.

Null Input

If input is null, the train's exception is set to "Input ({typeof(TInput)}) is null." and subsequent steps are short-circuited.

Remarks

  • Memory is initialized with Unit.Default under typeof(Unit), allowing parameterless junction invocations.
  • The otherInputs parameter follows the same tuple/interface storage rules as the primary input.
  • See Memory for details on how the type-keyed dictionary works.