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 cdmdotnet.Logging;
11 : using Cqrs.Configuration;
12 :
13 : namespace Cqrs.Domain
14 : {
15 : public abstract class SagaEventHandler<TAuthenticationToken, TSaga>
16 : where TSaga : ISaga<TAuthenticationToken>
17 0 : {
18 : protected ISagaUnitOfWork<TAuthenticationToken> SagaUnitOfWork { get; private set; }
19 :
20 : protected IDependencyResolver DependencyResolver { get; private set; }
21 :
22 : protected ILogger Logger { get; private set; }
23 :
24 : /// <summary>
25 : /// A constructor for the <see cref="Cqrs.Domain.Factories.IAggregateFactory"/>
26 : /// </summary>
27 1 : protected SagaEventHandler(IDependencyResolver dependencyResolver, ILogger logger)
28 : : this(dependencyResolver, logger, dependencyResolver.Resolve<ISagaUnitOfWork<TAuthenticationToken>>())
29 : {
30 : }
31 :
32 0 : protected SagaEventHandler(IDependencyResolver dependencyResolver, ILogger logger, ISagaUnitOfWork<TAuthenticationToken> sagaUnitOfWork)
33 : {
34 : DependencyResolver = dependencyResolver;
35 : Logger = logger;
36 : SagaUnitOfWork = sagaUnitOfWork;
37 : }
38 :
39 0 : protected virtual TSaga GetSaga(Guid id)
40 : {
41 : return SagaUnitOfWork.Get<TSaga>(id);
42 : }
43 : }
44 : }
|