Line data Source code
1 : #region Copyright
2 : // // -----------------------------------------------------------------------
3 : // // <copyright company="cdmdotnet Limited">
4 : // // Copyright cdmdotnet Limited. All rights reserved.
5 : // // </copyright>
6 : // // -----------------------------------------------------------------------
7 : #endregion
8 :
9 : using Cqrs.Domain;
10 :
11 : namespace Cqrs.Snapshots
12 : {
13 : public abstract class SnapshotAggregateRoot<TAuthenticationToken, TSnapshot> : AggregateRoot<TAuthenticationToken>
14 : where TSnapshot : Snapshot
15 0 : {
16 0 : public TSnapshot GetSnapshot()
17 : {
18 : TSnapshot snapshot = CreateSnapshot();
19 : snapshot.Id = Id;
20 : return snapshot;
21 : }
22 :
23 0 : public void Restore(TSnapshot snapshot)
24 : {
25 : Id = snapshot.Id;
26 : Version = snapshot.Version;
27 : RestoreFromSnapshot(snapshot);
28 : }
29 :
30 0 : protected abstract TSnapshot CreateSnapshot();
31 :
32 0 : protected abstract void RestoreFromSnapshot(TSnapshot snapshot);
33 : }
34 : }
|