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 System.Collections.Generic;
11 : using System.Runtime.Serialization;
12 : using Cqrs.Domain;
13 : using Cqrs.Messages;
14 :
15 : namespace Cqrs.Commands
16 : {
17 : /// <summary>
18 : /// A <see cref="ICommand{TAuthenticationToken}"/> for <see cref="IDto"/> objects
19 : /// </summary>
20 : /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of authentication token.</typeparam>
21 : /// <typeparam name="TDto">The <see cref="Type"/> of <see cref="IDto"/> this command targets.</typeparam>
22 : [Serializable]
23 : [DataContract]
24 : public class DtoCommand<TAuthenticationToken, TDto> : ICommand<TAuthenticationToken>
25 : where TDto : IDto
26 1 : {
27 : /// <summary>
28 : /// Gets or sets the original version of the <typeparamref name="TDto"/>.
29 : /// </summary>
30 : [DataMember]
31 : public TDto Original { get; set; }
32 :
33 : /// <summary>
34 : /// Gets or sets the new version of the <typeparamref name="TDto"/>.
35 : /// </summary>
36 : [DataMember]
37 : public TDto New { get; set; }
38 :
39 : /// <summary>
40 : /// Instantiates a new instance of <see cref="DtoCommand{TAuthenticationToken,TDto}"/>
41 : /// </summary>
42 1 : public DtoCommand(Guid id, TDto original, TDto @new)
43 : {
44 : Id = id;
45 : Original = original;
46 : New = @new;
47 : }
48 :
49 : /// <summary>
50 : /// The identifier of the command itself.
51 : /// In some cases this may be the <see cref="IAggregateRoot{TAuthenticationToken}"/> or <see cref="ISaga{TAuthenticationToken}"/> this command targets.
52 : /// </summary>
53 : [DataMember]
54 : public Guid Id { get; set; }
55 :
56 : /// <summary>
57 : /// The expected version number the targeted <see cref="IAggregateRoot{TAuthenticationToken}"/> or <see cref="ISaga{TAuthenticationToken}"/> is expected to be.
58 : /// </summary>
59 : [DataMember]
60 : public int ExpectedVersion { get; set; }
61 :
62 : #region Implementation of IMessageWithAuthenticationToken<TAuthenticationToken>
63 :
64 : /// <summary>
65 : /// The <typeparamref name="TAuthenticationToken"/> of the entity that triggered the event to be raised.
66 : /// </summary>
67 : [DataMember]
68 : public TAuthenticationToken AuthenticationToken { get; set; }
69 :
70 : #endregion
71 :
72 : #region Implementation of IMessage
73 :
74 : /// <summary>
75 : /// An identifier used to group together several <see cref="IMessage"/>. Any <see cref="IMessage"/> with the same <see cref="CorrelationId"/> were triggered by the same initiating request.
76 : /// </summary>
77 : [DataMember]
78 : public Guid CorrelationId { get; set; }
79 :
80 : /// <summary>
81 : /// The originating framework this message was sent from.
82 : /// </summary>
83 : [DataMember]
84 : public string OriginatingFramework { get; set; }
85 :
86 : /// <summary>
87 : /// The frameworks this <see cref="IMessage"/> has been delivered to/sent via already.
88 : /// </summary>
89 : [DataMember]
90 : public IEnumerable<string> Frameworks { get; set; }
91 :
92 : #endregion
93 : }
94 : }
|