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 : /// An <see cref="IAggregateRoot{TAuthenticationToken}"/> for operating on <see cref="IDto"/> instances.
16 : /// </summary>
17 : /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of authentication token.</typeparam>
18 : /// <typeparam name="TDto">The <see cref="Type"/> of <see cref="IDto"/>.</typeparam>
19 : public class DtoAggregateRoot<TAuthenticationToken, TDto> : AggregateRoot<TAuthenticationToken>
20 : where TDto : IDto
21 1 : {
22 : /// <summary>
23 : /// Instantiate a new instance of <see cref="DtoAggregateRoot{TAuthenticationToken,TDto}"/>
24 : /// and instantly apply the change as n <see cref="DtoAggregateEvent{TAuthenticationToken,TDto}"/>
25 : /// </summary>
26 : /// <param name="id">The identifier of the <see cref="IDto"/>.</param>
27 : /// <param name="original">The original copy of the <see cref="IDto"/>. May be null for a <see cref="DtoAggregateEventType.Created"/> operation.</param>
28 : /// <param name="new">The new copy of the <see cref="IDto"/>. May be null for a <see cref="DtoAggregateEventType.Deleted"/> operation.</param>
29 1 : public DtoAggregateRoot(Guid id, TDto original, TDto @new)
30 : {
31 : Id = id;
32 : ApplyChange(new DtoAggregateEvent<TAuthenticationToken, TDto>(id, original, @new));
33 : }
34 : }
35 : }
|