forked from Chinchilla-Software-Com/CQRS
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chinchilla-Software-Com#13 Updated the tests to properly show how to …
…create a proper event handler that locates the correct saga. Chinchilla-Software-Com#14 Correctly use the right resolver in the correct way.
- Loading branch information
greyoy
committed
Jun 13, 2017
1 parent
1edc83c
commit b972fb0
Showing
6 changed files
with
145 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#region Copyright | ||
// // ----------------------------------------------------------------------- | ||
// // <copyright company="cdmdotnet Limited"> | ||
// // Copyright cdmdotnet Limited. All rights reserved. | ||
// // </copyright> | ||
// // ----------------------------------------------------------------------- | ||
#endregion | ||
|
||
using System; | ||
using cdmdotnet.Logging; | ||
using Cqrs.Configuration; | ||
|
||
namespace Cqrs.Domain | ||
{ | ||
public abstract class SagaEventHandler<TAuthenticationToken, TSaga> | ||
where TSaga : ISaga<TAuthenticationToken> | ||
{ | ||
protected ISagaUnitOfWork<TAuthenticationToken> SagaUnitOfWork { get; private set; } | ||
|
||
protected IDependencyResolver DependencyResolver { get; private set; } | ||
|
||
protected ILogger Logger { get; private set; } | ||
|
||
/// <summary> | ||
/// A constructor for the <see cref="Cqrs.Domain.Factories.IAggregateFactory"/> | ||
/// </summary> | ||
protected SagaEventHandler(IDependencyResolver dependencyResolver, ILogger logger) | ||
: this(dependencyResolver, logger, dependencyResolver.Resolve<ISagaUnitOfWork<TAuthenticationToken>>()) | ||
{ | ||
} | ||
|
||
protected SagaEventHandler(IDependencyResolver dependencyResolver, ILogger logger, ISagaUnitOfWork<TAuthenticationToken> sagaUnitOfWork) | ||
{ | ||
DependencyResolver = dependencyResolver; | ||
Logger = logger; | ||
SagaUnitOfWork = sagaUnitOfWork; | ||
} | ||
|
||
protected virtual TSaga GetSaga(Guid id) | ||
{ | ||
return SagaUnitOfWork.Get<TSaga>(id); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters