コード例 #1
0
        public PersistBySnapshotTestActor()
        {
            _state = new TestActorState();

            Recover <SnapshotOffer>(offer => {
                _log.Info("SnapshotOffer received.");
                _state = offer.Snapshot as TestActorState;
            });

            Command <SetStateCommand>(cmd => {
                _state.State = cmd.NewState;
                SaveSnapshot(_state);
            });
            Command <GetStateCommand>(cmd => {
                Sender.Tell(_state.State);
            });
        }
コード例 #2
0
        public PersistByJournalTestActor()
        {
            _state = new TestActorState();

            Recover <SetStateCommand>(cmd => {
                _log.Info("Recovering SetStateCommand.");
                _state.State = cmd.NewState;
            });

            Recover <SnapshotOffer>(offer => {
                _log.Info("SnapshotOffer received.");
                _state = offer.Snapshot as TestActorState;
            });

            Command <SetStateCommand>(cmd => {
                Persist(cmd, action => {
                    _state.State = cmd.NewState;
                });
            });

            Command <GetStateCommand>(cmd => {
                Sender.Tell(_state.State);
            });
        }