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 System;
10 : using System.Collections.Generic;
11 : using Akka.Actor;
12 : using Cqrs.Akka.Domain.Commands;
13 : using Cqrs.Domain;
14 : using Cqrs.Events;
15 :
16 : namespace Cqrs.Akka.Domain
17 : {
18 : public class AkkaAggregateRootProxy<TAuthenticationToken, TAggregateRoot>
19 : : IAkkaAggregateRootProxy<TAggregateRoot>
20 : , IAggregateRoot<TAuthenticationToken>
21 : // TODO think about if this is necessary again.
22 : // where TAggregateRoot : IAggregateRoot<TAuthenticationToken>
23 0 : {
24 : public IActorRef ActorReference { get; internal set; }
25 :
26 : public TAggregateRoot Aggregate { get; protected set; }
27 :
28 : #region Implementation of IAggregateRoot<TAuthenticationToken>
29 :
30 : public virtual Guid Id
31 : {
32 : get { return ActorReference.Ask<Guid>(new GetAkkaAggregateRootId()).Result; }
33 : }
34 :
35 : public virtual int Version
36 : {
37 : get { return ActorReference.Ask<int>(new GetAkkaAggregateRootVersion()).Result; }
38 : }
39 :
40 0 : public virtual IEnumerable<IEvent<TAuthenticationToken>> GetUncommittedChanges()
41 : {
42 : return ((IAggregateRoot<TAuthenticationToken>)Aggregate).GetUncommittedChanges();
43 : }
44 :
45 0 : public virtual void MarkChangesAsCommitted()
46 : {
47 : ((IAggregateRoot<TAuthenticationToken>)Aggregate).MarkChangesAsCommitted();
48 : }
49 :
50 0 : public virtual void LoadFromHistory(IEnumerable<IEvent<TAuthenticationToken>> history)
51 : {
52 : ((IAggregateRoot<TAuthenticationToken>)Aggregate).LoadFromHistory(history);
53 : }
54 :
55 : #endregion
56 : }
57 : }
|