Line data Source code
1 : #region Copyright
2 : // // -----------------------------------------------------------------------
3 : // // <copyright company="Chinchilla Software Limited">
4 : // // Copyright Chinchilla Software Limited. All rights reserved.
5 : // // </copyright>
6 : // // -----------------------------------------------------------------------
7 : #endregion
8 :
9 : using System;
10 : using Cqrs.Domain;
11 : using Cqrs.Snapshots;
12 :
13 : namespace Cqrs.Akka.Snapshots
14 : {
15 : /// <summary>
16 : /// An <see cref="DefaultSnapshotStrategy{TAuthenticationToken}"/> for Akka.
17 : /// </summary>
18 : /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of the authentication token.</typeparam>
19 : public class DefaultAkkaSnapshotStrategy<TAuthenticationToken> : DefaultSnapshotStrategy<TAuthenticationToken>
20 1 : {
21 : /// <summary>
22 : /// Indicates if the <paramref name="aggregateType"/> is able to be snapshotted by checking if the <paramref name="aggregateType"/>
23 : /// directly inherits <see cref="SnapshotAggregateRoot{TAuthenticationToken,TSnapshot}"/>
24 : /// </summary>
25 : /// <param name="aggregateType">The <see cref="Type"/> of <see cref="IAggregateRoot{TAuthenticationToken}"/> to check.</param>
26 1 : public override bool IsSnapshotable(Type aggregateType)
27 : {
28 : if (aggregateType.BaseType == null)
29 : return false;
30 : if (aggregateType.BaseType.IsGenericType && (aggregateType.BaseType.GetGenericTypeDefinition() == typeof(AkkaSnapshotAggregateRoot<,>) || aggregateType.BaseType.GetGenericTypeDefinition() == typeof(SnapshotAggregateRoot<,>)))
31 : return true;
32 : return IsSnapshotable(aggregateType.BaseType);
33 : }
34 : }
35 : }
|