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.Events
16 : {
17 : /// <summary>
18 : /// An <see cref="IEvent{TAuthenticationToken}"/> used specifically by a <see cref="ISaga{TAuthenticationToken}"/>
19 : /// </summary>
20 : /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of the authentication token.</typeparam>
21 : public class SagaEvent<TAuthenticationToken>
22 : : ISagaEvent<TAuthenticationToken>
23 1 : {
24 : /// <summary>
25 : /// Instantiates a new instance of <see cref="SagaEvent{TAuthenticationToken}"/>.
26 : /// </summary>
27 1 : public SagaEvent() { }
28 :
29 : /// <summary>
30 : /// Instantiates a new instance of <see cref="SagaEvent{TAuthenticationToken}"/> with the provided <paramref name="event"/>.
31 : /// </summary>
32 1 : public SagaEvent(IEvent<TAuthenticationToken> @event)
33 : {
34 : Event = @event;
35 : }
36 :
37 : #region Implementation of IMessage
38 :
39 : /// <summary>
40 : /// 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.
41 : /// </summary>
42 : [DataMember]
43 : public Guid CorrelationId { get; set; }
44 :
45 : /// <summary>
46 : /// The originating framework this message was sent from.
47 : /// </summary>
48 : [DataMember]
49 : public string OriginatingFramework { get; set; }
50 :
51 : /// <summary>
52 : /// The frameworks this <see cref="IMessage"/> has been delivered to/sent via already.
53 : /// </summary>
54 : [DataMember]
55 : public IEnumerable<string> Frameworks { get; set; }
56 :
57 : #endregion
58 :
59 : #region Implementation of IMessageWithAuthenticationToken<TAuthenticationToken>
60 :
61 : /// <summary>
62 : /// The <typeparamref name="TAuthenticationToken"/> of the entity that triggered the event to be raised.
63 : /// </summary>
64 : [DataMember]
65 : public TAuthenticationToken AuthenticationToken { get; set; }
66 :
67 : #endregion
68 :
69 : #region Implementation of IEvent<TAuthenticationToken,TEvent>
70 :
71 : /// <summary>
72 : /// The ID of the <see cref="IEvent{TAuthenticationToken}"/>
73 : /// </summary>
74 : [DataMember]
75 : public Guid Id { get; set; }
76 :
77 : /// <summary>
78 : /// The version of the <see cref="IEvent{TAuthenticationToken}"/>
79 : /// </summary>
80 : [DataMember]
81 : public int Version { get; set; }
82 :
83 : /// <summary>
84 : /// The date and time the event was raised or published.
85 : /// </summary>
86 : [DataMember]
87 : public DateTimeOffset TimeStamp { get; set; }
88 :
89 : #endregion
90 :
91 : #region Implementation of ISagaEvent<TAuthenticationToken,TEvent>
92 :
93 : /// <summary>
94 : /// The <see cref="IEvent{TAuthenticationToken}"/> this <see cref="ISagaEvent{TAuthenticationToken}"/> encases.
95 : /// </summary>
96 : [DataMember]
97 : public IEvent<TAuthenticationToken> Event { get; set; }
98 :
99 : #endregion
100 : }
101 : }
|