private ErrorsHandler(string tag, TInput stackInput, TState state, IStackEvents <TOperationEvent> stackEvents, Func <TError, bool> filter = null, bool?handled = null, bool handle = false) : base(tag, stackInput, state, stackEvents) { errors = stackEvents.FilterErrors(handled, filter); if (handle) { foreach (var e in errors) { e.Handle(); } } IsEmptyEventBlock = !errors.Any(); }
public override StackBlockBase <TState> CreateBlock(TState state, IStackEvents stackEvents, object input) { if (func != null) { return(new Query <TState, TResult>(Tag, state, stackEvents, func)); } else if (typedFunc != null) { return(new Query <TState, TResult>(Tag, state, stackEvents, typedFunc)); } else { return(new Query <TState, TResult>(Tag, state, stackEvents, funcWithResult)); } }
public override StackBlockBase <TState> CreateBlock(TState state, IStackEvents stackEvents, object input) { if (func != null) { return(new Command <TState>(Tag, state, stackEvents, func)); } else if (action != null) { return(new Command <TState>(Tag, state, stackEvents, action)); } else { return(new Command <TState>(Tag, state, stackEvents, funcWithResult)); } }
public ExceptionsHandler(string tag, TInput stackInput, TState state, IStackEvents <TOperationEvent> stackEvents, Func <IExceptionsErrorHandler <TEvent, TException, TInput, TState, TOperationEvent>, BlockResultVoid> func, Func <IOperationExceptionError <TEvent, TException>, bool> filter = null, bool?handled = null, bool handle = false) : this(tag, stackInput, state, stackEvents, filter, handled, handle) { executor = () => func(this); }
public ErrorsHandler(string tag, TInput stackInput, TState state, Emptyable <Tin> input, IStackEvents <TOperationEvent> stackEvents, Func <IErrorsHandler <TError, TInput, TState, TOperationEvent, Tin>, BlockResult <Tin> > func, Func <TError, bool> filter = null, bool?handled = null, bool handle = false) : this(tag, stackInput, state, input, stackEvents, filter, handled, handle) { executor = () => func(this); }
internal QueryBlock(string tag, TInput stackInput, TState state, IStackEvents <TOperationEvent> stackEvents, Func <IOperationBlock <TInput, TState, TOperationEvent>, Task <IQueryResult <TOperationEvent, TResult> > > func) : base(tag, stackInput, state, stackEvents) { executorAsync = async() => { var r = await func(this).ConfigureAwait(false); this.Append(r); return(resultDispatcher.Return(r.Result.Value)); }; }
internal QueryBlock(string tag, TInput stackInput, TState state, IStackEvents <TOperationEvent> stackEvents, Func <IOperationBlock <TInput, TState, TOperationEvent>, IQueryResult <TOperationEvent, TResult> > func) : base(tag, stackInput, state, stackEvents) { executor = () => { var r = func(this); this.Append(r); return(resultDispatcher.Return(r.Result.Value)); }; }
protected QueryBlock(string tag, TInput stackInput, TState state, IStackEvents <TOperationEvent> stackEvents) : base(tag, stackInput, state, stackEvents) { }
public StackBlockBase(string tag, TInput input, TState state, IStackEvents <TOperationEvent> stackEvents) : base(tag, stackEvents) { StackState = state; StackInput = input; }
public override StackBlockBase <TInput, TState, TOperationEvent> CreateBlock(TInput stackInput, TState state, IStackEvents <TOperationEvent> stackEvents, IEmptyable input) { return(blockBuilder(stackInput, state, stackEvents, input)); }
public abstract StackBlockBase <TState> CreateBlock(TState state, IStackEvents stackEvents, object input);
internal EventHandlerBlockBase(string tag, TInput stackInput, TState state, Emptyable <Tin> input, IStackEvents <TOperationEvent> stackEvents) : base(tag, stackInput, state, stackEvents) { Input = input; }
public EventsHandler(string tag, TInput stackInput, TState state, Emptyable <Tin> input, IStackEvents <TOperationEvent> stackEvents, Func <IEventsHandler <TEvent, TInput, TState, TOperationEvent, Tin>, BlockResult <Tin> > func, Func <TEvent, bool> filter = null) : this(tag, stackInput, state, input, stackEvents, filter) { executor = () => func(this); }
private EventsHandler(string tag, TInput stackInput, TState state, Emptyable <Tin> input, IStackEvents <TOperationEvent> stackEvents, Func <TEvent, bool> filter = null) : base(tag, stackInput, state, input, stackEvents) { Input = input; events = stackEvents.FilterErrors(null, filter); IsEmptyEventBlock = !events.Any(); }
public ExceptionsHandler(string tag, TInput stackInput, TState state, IStackEvents <TOperationEvent> stackEvents, Action <IExceptionsErrorHandler <TEvent, TException, TInput, TState, TOperationEvent> > action, Func <IOperationExceptionError <TEvent, TException>, bool> filter = null, bool?handled = null, bool handle = false) : this(tag, stackInput, state, stackEvents, filter, handled, handle) { executor = () => { action(this); return(Return()); }; }
internal CommandBlock(string tag, TInput input, TState state, IStackEvents <TOperationEvent> stackEvents, Func <ICommand <TInput, TState, TOperationEvent>, Task> actionAsync) : base(tag, input, state, stackEvents) { executorAsync = async() => { await actionAsync(this).ConfigureAwait(false); return(resultDispatcher.Return()); }; }
internal CommandBlock(string tag, TInput input, TState state, IStackEvents <TOperationEvent> stackEvents, ICommandOperation <TOperationEvent> commandOperation) : base(tag, input, state, stackEvents) { if (commandOperation.SupportsAsync && commandOperation.PreferAsync) { executor = () => { ICommandResult <TOperationEvent> r; if (commandOperation is ICommandOperationWithState <TState, TOperationEvent> operationWithState) { r = operationWithState.Execute(state); } else { r = commandOperation.Execute(); } this.Append(r); return(resultDispatcher.Return()); } } ; else { executorAsync = async() => { ICommandResult <TOperationEvent> r; if (commandOperation is ICommandOperationWithState <TState, TOperationEvent> operationWithState) { r = operationWithState.Execute(state); } else { r = await commandOperation.ExecuteAsync().ConfigureAwait(false); } this.Append(r); return(resultDispatcher.Return()); } }; } //internal CommandBlock(string tag, TInput input, TState state, IStackEvents<TOperationEvent> stackEvents, ICommandOperationWithState<TState, TOperationEvent> commandOperation) // : base(tag, input, state, stackEvents) //{ // if (commandOperation.SupportsAsync && commandOperation.PreferAsync) // executor = () => { var r = commandOperation.Execute(state); this.Append(r); this.StackState = (TState)r.StackState; return resultDispatcher.Return(); }; // else // executorAsync = async () => { var r = await commandOperation.ExecuteAsync(state).ConfigureAwait(false); this.Append(r); this.StackState = (TState)r.StackState; return resultDispatcher.Return(); }; //} BlockResultVoid IResultVoidDispatcher <TState> .Fail() { return(resultDispatcher.Fail()); } BlockResultVoid IResultVoidDispatcher <TState> .Fail(OperationEvent error) { return(resultDispatcher.Fail(error)); } BlockResultVoid IResultVoidDispatcher <TState> .Complete() { return(resultDispatcher.Complete()); } BlockResultVoid IResultVoidDispatcher <TState> .Complete(object overrideResult) { return(resultDispatcher.Complete(overrideResult)); } BlockResultVoid IResultVoidDispatcher <TState> .Reset() { return(resultDispatcher.Reset()); } BlockResultVoid IResultVoidDispatcher <TState> .Reset(TState state) { return(resultDispatcher.Reset(state)); } BlockResultVoid IResultVoidDispatcher <TState> .Restart() { return(resultDispatcher.Restart()); } BlockResultVoid IResultVoidDispatcher <TState> .Return() { return(resultDispatcher.Return()); } BlockResultVoid IResultVoidDispatcher <TState> .Goto(string tag) { return(resultDispatcher.Goto(tag)); } BlockResultVoid IResultVoidDispatcher <TState> .Goto(string tag, object overrideInput) { return(resultDispatcher.Goto(tag, overrideInput)); } BlockResultVoid IResultVoidDispatcher <TState> .Goto(int index) { return(resultDispatcher.Goto(index)); } BlockResultVoid IResultVoidDispatcher <TState> .Goto(int index, object overrideInput) { return(resultDispatcher.Goto(index, overrideInput)); } BlockResultVoid IResultVoidDispatcher <TState> .Skip(int i) { return(resultDispatcher.Skip(i)); } BlockResultVoid IResultVoidDispatcher <TState> .Skip(int i, object overrideInput) { return(resultDispatcher.Skip(i, overrideInput)); } BlockResultVoid IResultVoidDispatcher <TState> .Retry() { return(resultDispatcher.Retry()); } BlockResultVoid IResultVoidDispatcher <TState> .Retry(object overrideInput) { return(resultDispatcher.Retry(overrideInput)); } }
public abstract StackBlockBase <TInput, TState, TOperationEvent> CreateBlock(TInput stackInput, TState state, IStackEvents <TOperationEvent> stackEvents, IEmptyable input);
public EventHandlerBlockBase(string tag, TInput stackInput, TState state, IStackEvents <TOperationEvent> stackEvents) : base(tag, stackInput, state, stackEvents) { }
protected CommandBlock(string tag, TInput input, TState state, IStackEvents <TOperationEvent> stackEvents) : base(tag, input, state, stackEvents) { }
public StackBlockBase(string tag, IStackEvents <TOperationEvent> stackEvents) { Tag = tag; StackEvents = stackEvents; }
internal CommandBlock(string tag, TInput input, TState state, IStackEvents <TOperationEvent> stackEvents, Func <ICommand <TInput, TState, TOperationEvent>, BlockResultVoid> func) : base(tag, input, state, stackEvents) { executor = () => func(this); }
internal QueryBlock(string tag, TInput stackInput, TState state, IStackEvents <TOperationEvent> stackEvents, Func <ITypedQuery <TInput, TState, TOperationEvent, TResult>, BlockResult <TResult> > func) : base(tag, stackInput, state, stackEvents) { executor = () => func(this); }
internal CommandBlock(string tag, TInput input, TState state, IStackEvents <TOperationEvent> stackEvents, Action <ICommand <TInput, TState, TOperationEvent> > action) : base(tag, input, state, stackEvents) { executor = () => { action(this); return(resultDispatcher.Return()); }; }
internal QueryBlock(string tag, TInput stackInput, TState state, IStackEvents <TOperationEvent> stackEvents, Func <ITypedQuery <TInput, TState, TOperationEvent, TResult>, Task <BlockResult <TResult> > > func) : base(tag, stackInput, state, stackEvents) { executorAsync = async() => await func(this).ConfigureAwait(false); }
internal CommandBlock(string tag, TInput input, TState state, IStackEvents <TOperationEvent> stackEvents, Func <IOperationBlock <TInput, TState, TOperationEvent>, ICommandResult <TOperationEvent> > func) : base(tag, input, state, stackEvents) { executor = () => { var r = func(this); this.Append(r); return(resultDispatcher.Return()); }; }
internal QueryBlock(string tag, TInput stackInput, TState state, IStackEvents <TOperationEvent> stackEvents, IQueryOperation <TOperationEvent, TResult> queryOperation) : base(tag, stackInput, state, stackEvents) { if (queryOperation.SupportsAsync && queryOperation.PreferAsync) { executor = () => { IQueryResult <TOperationEvent, TResult> r; if (queryOperation is IQueryOperationWithState <TState, TOperationEvent, TResult> queryOperationWithState) { r = queryOperationWithState.Execute(state); } else { r = queryOperation.Execute(); } this.Append(r); return(resultDispatcher.Return(r.Result.Value)); } } ; else { executorAsync = async() => { IQueryResult <TOperationEvent, TResult> r; if (queryOperation is IQueryOperationWithState <TState, TOperationEvent, TResult> queryOperationWithState) { r = await queryOperationWithState.ExecuteAsync(state).ConfigureAwait(false); } else { r = await queryOperation.ExecuteAsync().ConfigureAwait(false); } this.Append(r); return(resultDispatcher.Return(r.Result.Value)); } }; } IQueryResultProxy <T, TState> IQuery <TInput, TState, TOperationEvent> .DefineResult <T>() { return(new QueryResultProxy <T, TState>()); } IQueryResultProxy <T, TState> IQuery <TInput, TState, TOperationEvent> .DefineResult <T>(T result) { return(new QueryResultProxy <T, TState>() { Result = result }); } IQueryResultProxy <T, TState> IQuery <TInput, TState, TOperationEvent> .DefineResult <T>(Expression <Func <T> > expression) { return(new QueryResultProxy <T, TState>()); } BlockResult <T> IResultDispatcher <TState> .Fail <T>() { return(new ResultDispatcher <T, TState>().Fail()); } BlockResult <T> IResultDispatcher <TState> .Fail <T>(OperationEvent error) { return(new ResultDispatcher <T, TState>().Fail(error)); } BlockResult <T> IResultDispatcher <TState> .Complete <T>() { return(new ResultDispatcher <T, TState>().Complete()); } BlockResult <T> IResultDispatcher <TState> .Complete <T>(object overrideResult) { return(new ResultDispatcher <T, TState>().Complete(overrideResult)); } BlockResult <T> IResultDispatcher <TState> .Reset <T>() { return(new ResultDispatcher <T, TState>().Reset()); } BlockResult <T> IResultDispatcher <TState> .Reset <T>(TState state) { return(new ResultDispatcher <T, TState>().Reset(state)); } BlockResult <T> IResultDispatcher <TState> .Restart <T>() { return(new ResultDispatcher <T, TState>().Restart()); } BlockResult <T> IResultDispatcher <TState> .Return <T>(T result) { return(new ResultDispatcher <T, TState>().Return(result)); } BlockResult <T> IResultDispatcher <TState> .Goto <T>(string tag) { return(new ResultDispatcher <T, TState>().Goto(tag)); } BlockResult <T> IResultDispatcher <TState> .Goto <T>(string tag, object overrideInput) { return(new ResultDispatcher <T, TState>().Goto(tag, overrideInput)); } BlockResult <T> IResultDispatcher <TState> .Goto <T>(int index) { return(new ResultDispatcher <T, TState>().Goto(index)); } BlockResult <T> IResultDispatcher <TState> .Goto <T>(int index, object overrideInput) { return(new ResultDispatcher <T, TState>().Goto(index, overrideInput)); } BlockResult <T> IResultDispatcher <TState> .Skip <T>(int i) { return(new ResultDispatcher <T, TState>().Skip(i)); } BlockResult <T> IResultDispatcher <TState> .Skip <T>(int i, object overrideInput) { return(new ResultDispatcher <T, TState>().Skip(i, overrideInput)); } BlockResult <T> IResultDispatcher <TState> .Retry <T>() { return(new ResultDispatcher <T, TState>().Retry()); } BlockResult <T> IResultDispatcher <TState> .Retry <T>(object overrideInput) { return(new ResultDispatcher <T, TState>().Retry(overrideInput)); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Return(TResult result) { return(resultDispatcher.Return(result)); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Complete() { return(resultDispatcher.Complete()); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Complete(object overrideResult) { return(resultDispatcher.Complete(overrideResult)); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Fail() { return(resultDispatcher.Fail()); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Fail(OperationEvent error) { return(resultDispatcher.Fail(error)); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Reset() { return(resultDispatcher.Reset()); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Reset(TState state) { return(resultDispatcher.Reset(state)); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Restart() { return(resultDispatcher.Restart()); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Goto(string tag) { return(resultDispatcher.Goto(tag)); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Goto(string tag, object overrideInput) { return(resultDispatcher.Goto(tag, overrideInput)); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Goto(int index) { return(resultDispatcher.Goto(index)); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Goto(int index, object overrideInput) { return(resultDispatcher.Goto(index, overrideInput)); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Skip(int i) { return(resultDispatcher.Skip(i)); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Skip(int i, object overrideInput) { return(resultDispatcher.Skip(i, overrideInput)); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Retry() { return(resultDispatcher.Retry()); } BlockResult <TResult> IResultDispatcher <TResult, TState> .Retry(object overrideInput) { return(resultDispatcher.Retry(overrideInput)); } }
internal CommandBlock(string tag, TInput input, TState state, IStackEvents <TOperationEvent> stackEvents, Func <ICommand <TInput, TState, TOperationEvent>, Task <BlockResultVoid> > func) : base(tag, input, state, stackEvents) { executorAsync = async() => await func(this).ConfigureAwait(false); }
public ErrorsHandler(string tag, TInput stackInput, TState state, Emptyable <Tin> input, IStackEvents <TOperationEvent> stackEvents, Action <IErrorsHandler <TError, TInput, TState, TOperationEvent, Tin> > action, Func <TError, bool> filter = null, bool?handled = null, bool handle = false) : this(tag, stackInput, state, input, stackEvents, filter, handled, handle) { executor = () => { action(this); return(Return(input.Value)); }; }
public ExceptionsHandler(string tag, TInput stackInput, TState state, Emptyable <Tin> input, IStackEvents <TOperationEvent> stackEvents, Func <IOperationExceptionError <TEvent, TException>, bool> filter = null, bool?handled = null, bool handle = false) : base(tag, stackInput, state, input, stackEvents) { Input = input; errors = stackEvents.FilterExceptions(handled, filter); if (handle) { foreach (var e in errors) { e.Error.Handle(); } } IsEmptyEventBlock = !errors.Any(); }