Beispiel #1
0
 public void HandleSnapshot(Any anySnapshot, ISnapshotContext context)
 {
     Unwrap(() =>
     {
         var snapshot = AnySupport.Decode(anySnapshot);
         if (!CurrentBehaviors.Any(behavior => BehaviorReflectionCache.GetOrAdd(behavior.GetType())
                                   .GetSnapshotHandler(snapshot.GetType())
                                   .Match(handler =>
         {
             var active = true;
             var ctx = new SnapshotBehaviorContext(context, behaviors =>
             {
                 // TODO: Check sequence number override on this context is set correctly.
                 // ReSharper disable once AccessToModifiedClosure
                 if (!active)
                 {
                     throw new InvalidOperationException("Context is not active!");
                 }
                 CurrentBehaviors = ValidateBehaviors(behaviors).ToArray();
             });
             handler.Invoke(behavior, snapshot, ctx);
             active = false;
             return(true);
         }, () => false))
             )
         {
             throw new CloudStateException(
                 $"No snapshot handler found for snapshot [{snapshot.GetType()}] on any of the current behaviors [{BehaviorsString}]"
                 );
         }
     });
 }
Beispiel #2
0
            public MockSnapshotContextRef(long seq = 1L)
            {
                var context = new Mock <ISnapshotContext>();

                context.Setup(x => x.SequenceNumber).Returns(seq);
                context.Setup(x => x.EntityId).Returns("foo");
                Object = context.Object;
            }
Beispiel #3
0
 public Option <Any> Snapshot(ISnapshotContext context)
 {
     throw new NotImplementedException();
 }