示例#1
0
        public (bool, object) Apply(LocalEvent e)
        {
            object obj;

            try
            {
                using (var sync = _sequenceNr.Lock())
                {
                    if (!_sequenceNr.IsValidSequence(e.SequenceNr))
                    {
                        return(false, null);
                    }
                    obj = _apply[e.GetType()](e);
                    _sequenceNr.Set(e.SequenceNr);
                    return(true, obj);
                }
            }
            catch { return(false, null); }
        }
 public async Task <bool> Materialize(IAsyncEnumerable <NetworkEvent> events)
 {
     try
     {
         using (var sync = await _sequenceNr.LockAsync())
         {
             await foreach (var e in events)
             {
                 if (!_sequenceNr.IsValidSequence(e.SequenceNr))
                 {
                     return(false);
                 }
                 _apply[e.GetType()](e);
                 _sequenceNr.Set(e.SequenceNr);
             }
             return(true);
         }
     }
     catch (Exception e) when(e.StackTrace.Contains("IAsyncEnumerable"))
     {
         return(true);
     }                                                                                     // NB: SHOULD RETURN FALSE
     catch { return(false); }
 }