// injected storage provider public Copier([UseStorageProvider("copier")] IStorage <CopierState> storage) { this.storage = storage; var supervision = new Supervision(this); var fsm = new StateMachine() .State(Active, supervision.On) .Substate(Preparing, Trait.Of(Restartable), Durable) .Substate(Copying, Trait.Of(Restartable, Cancellable), Durable) .Substate(Restarting, Durable) .State(Inactive, supervision.Off) .Substate(Initial) .Substate(Suspended) .Substate(Completed, Trait.Of(Restartable), Durable) .Substate(Canceled, Trait.Of(Restartable), Durable); behavior = new Behavior(fsm); }
public Copier(IStorage <CopierData> data) { this.data = data; Receive Durable(Receive next) { return(async message => { var result = await next(message); if (message is Become) { await Save(); } return result; }); } Task <object> Active(object x) => TaskResult.Unhandled; Task <object> Inactive(object x) => TaskResult.Unhandled; var supervision = new Supervision(this); var fsm = new StateMachine() .State(Active, supervision.On) .Substate(Preparing, Durable) .Substate(Copying, Durable, trait: Cancellable) .Substate(Compressing, Durable, trait: Cancellable) .Substate(Cleaning, Durable) .State(Inactive, supervision.Off) .Substate(Initial) .Substate(Suspended, Durable) .Substate(Completed, Durable, trait: Resetable) .Substate(Canceled, Durable, trait: Resetable); behavior = new Behavior(fsm); behavior.Initial(Initial); }