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.Events;
11 :
12 : namespace Cqrs.Domain
13 : {
14 : /// <summary>
15 : /// Provides a basic container to control when <see cref="IEvent{TAuthenticationToken}">events</see> are store in an <see cref="IEventStore{TAuthenticationToken}"/> and then published on an <see cref="IEventPublisher{TAuthenticationToken}"/>.
16 : /// </summary>
17 : public interface IUnitOfWork<TAuthenticationToken>
18 : {
19 : /// <summary>
20 : /// Add an item into the <see cref="IUnitOfWork{TAuthenticationToken}"/> ready to be committed.
21 : /// </summary>
22 1 : void Add<TAggregateRoot>(TAggregateRoot aggregate)
23 : where TAggregateRoot : IAggregateRoot<TAuthenticationToken>;
24 :
25 : /// <summary>
26 : /// Get an item from the <see cref="IUnitOfWork{TAuthenticationToken}"/> if it has already been loaded.
27 : /// </summary>
28 1 : TAggregateRoot Get<TAggregateRoot>(Guid id, int? expectedVersion = null)
29 : where TAggregateRoot : IAggregateRoot<TAuthenticationToken>;
30 :
31 : /// <summary>
32 : /// Commit any changed <see cref="AggregateRoot{TAuthenticationToken}"/> added to this <see cref="IUnitOfWork{TAuthenticationToken}"/> via <see cref="Add{T}"/>
33 : /// </summary>
34 1 : void Commit();
35 : }
36 : }
|