Exemple #1
0
        public void QueryObjectResultedIn(IOutcome <StorageException, Result> outcome, QuerySingleResult result, object @object)
        {
            outcome
            .AndThen(good => good)
            .Otherwise(bad => throw new InvalidOperationException($"Bogus outcome: {bad.Message}"));

            _access.WriteUsing("add", result.StateObject);
        }
 public void WriteResultedIn <TState, TSource>(IOutcome <StorageException, Result> outcome, string id, TState state, int stateVersion, IEnumerable <Source <TSource> > sources, object @object)
 {
     outcome
     .AndThen(result => {
         _access.WriteUsing("writeStoreData", new StoreData <TSource>(1, result, state, sources, null, null));
         return(result);
     })
     .Otherwise(cause => {
         _access.WriteUsing("writeStoreData", new StoreData <TSource>(1, cause.Result, state, sources, null, cause));
         return(cause.Result);
     });
 }
Exemple #3
0
 public void AppendAllResultedIn <TSource, TSnapshotState>(IOutcome <StorageException, Result> outcome, string streamName, int streamVersion, IEnumerable <TSource> sources, Metadata metadata, Optional <TSnapshotState> snapshot, object @object) where TSource : Source
 {
     outcome.AndThen(result => {
         _access.WriteUsing("appendResultedIn",
                            new JournalData <TSource, TSnapshotState>(streamName, streamVersion, null, result, sources.ToList(), snapshot));
         return(result);
     }).Otherwise(cause => {
         _access.WriteUsing("appendResultedIn",
                            new JournalData <TSource, TSnapshotState>(streamName, streamVersion, cause, Result.Error, sources.ToList(), snapshot));
         return(cause.Result);
     });
 }
 public void ReadResultedIn <TState>(IOutcome <StorageException, Result> outcome, string id, TState state, int stateVersion, Metadata metadata, object @object)
 {
     outcome
     .AndThen(result => {
         _access.WriteUsing("readStoreData", new StoreData <TState>(1, result, state, new List <Source <TState> >(), metadata, null));
         return(result);
     })
     .Otherwise(cause => {
         _access.WriteUsing("readStoreData", new StoreData <TState>(1, cause.Result, state, new List <Source <TState> >(), metadata, cause));
         return(cause.Result);
     });
 }
 /// <inheritdoc />
 public void ReadResultedIn <TState>(IOutcome <StorageException, Result> outcome, string?id, TState state, int stateVersion, Metadata?metadata, object? @object)
 {
     outcome.AndThen(result =>
     {
         _readBundles.Add(new TypedStateBundle(id, state, stateVersion, metadata));
         return(result);
     })
     .Otherwise(cause =>
     {
         _readOutcome.Set(outcome);
         _success.Set(false);
         return(cause.Result);
     });
 }
 public void AppendResultedIn <TSource, TSnapshotState>(IOutcome <StorageException, Result> outcome, string streamName, int streamVersion, TSource source, Optional <TSnapshotState> snapshot, object @object) where TSource : ISource
 {
     outcome.AndThen(result => {
         _access.WriteUsing("appendResultedIn",
                            new JournalData <TSource, TState>(streamName, streamVersion, null, result, new List <TSource> {
             source
         }, snapshot.Map(s => (TState)(object)s)));
         return(result);
     }).Otherwise(cause => {
         _access.WriteUsing("appendResultedIn",
                            new JournalData <TSource, TState>(streamName, streamVersion, cause, Result.Error, new List <TSource> {
             source
         }, snapshot.Map(s => (TState)(object)s)));
         return(cause.Result);
     });
 }
 public void AppendResultedIn <TSource, TSnapshotState>(IOutcome <StorageException, Result> outcome,
                                                        string streamName, int streamVersion, TSource source,
                                                        Metadata metadata, Optional <TSnapshotState> snapshot, object @object) where TSource : ISource
 {
     //TODO handle metadata
     outcome
     .AndThen(result => {
         RestoreSnapshot(snapshot, _currentVersion);
         ApplyResultVersioned(source);
         AfterApply();
         CompleteUsing(@object);
         DisperseStowedMessages();
         return(result);
     })
     .Otherwise(cause => {
         var applicable     = new Applicable <TSnapshotState>(default !, new ISource[] { source }, metadata, (CompletionSupplier <TSnapshotState>)@object);
Exemple #8
0
 private void ReadConsidering <S>(IOutcome <StorageException, Result> outcome, S state)
 {
     outcome
     .AndThen(result =>
     {
         if (result == Result.Success)
         {
             Read(state);
         }
         return(result);
     })
     .Otherwise(ex =>
     {
         _exception.Set(ex);
         return(outcome.GetOrNull());
     });
 }
Exemple #9
0
 private void WrittenConsidering(IOutcome <StorageException, Result> outcome)
 {
     outcome
     .AndThen(result =>
     {
         if (result == Result.Success)
         {
             Written();
         }
         return(result);
     })
     .Otherwise(ex =>
     {
         _exception.Set(ex);
         return(outcome.GetOrNull());
     });
 }
 private void AppendConsidering <TSource, TSnapshotState>(IOutcome <StorageException, Result> outcome)
 {
     outcome
     .AndThen(result =>
     {
         if (result == Result.Success)
         {
             Appended();
         }
         return(result);
     })
     .Otherwise(ex =>
     {
         _exception.Set(ex);
         return(outcome.GetOrNull());
     });
 }
Exemple #11
0
 public void WriteResultedIn <TState, TSource>(IOutcome <StorageException, Result> outcome, string id, TState state, int stateVersion, IEnumerable <TSource> sources, object? @object)
 {
     outcome
     .AndThen(result => {
         Access.WriteUsing("writeTextResultedIn", 1);
         Access.WriteUsing("textWriteResult", result);
         Access.WriteUsing("stateHolder", state);
         Access.WriteUsing("textWriteAccumulatedResults", result);
         return(result);
     })
     .Otherwise(cause => {
         Access.WriteUsing("writeTextResultedIn", 1);
         Access.WriteUsing("textWriteResult", cause.Result);
         Access.WriteUsing("stateHolder", state);
         Access.WriteUsing("textWriteAccumulatedResults", cause.Result);
         Access.WriteUsing("errorCauses", cause);
         return(cause.Result);
     });
 }
Exemple #12
0
 public void ReadResultedIn <TState>(IOutcome <StorageException, Result> outcome, string?id, TState state, int stateVersion, Metadata?metadata, object? @object)
 {
     outcome
     .AndThen(result => {
         Access.WriteUsing("readTextResultedIn", 1);
         Access.WriteUsing("textReadResult", result);
         Access.WriteUsing("stateHolder", state);
         Access.WriteUsing("metadataHolder", metadata);
         return(result);
     })
     .Otherwise(cause => {
         Access.WriteUsing("readTextResultedIn", 1);
         Access.WriteUsing("textReadResult", cause.Result);
         Access.WriteUsing("stateHolder", state);
         Access.WriteUsing("metadataHolder", metadata);
         Access.WriteUsing("errorCauses", cause);
         return(cause.Result);
     });
 }