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.Runtime.Serialization;
11 : using Cqrs.Events;
12 :
13 : namespace Cqrs.Domain.Exceptions
14 : {
15 : /// <summary>
16 : /// The <see cref="IEventStore{TAuthenticationToken}"/> gave more than one <see cref="IEvent{TAuthenticationToken}"/>.
17 : /// </summary>
18 : /// <typeparam name="TAggregateRoot">The <see cref="Type"/> of the <see cref="IAggregateRoot{TAuthenticationToken}"/> that wasn't found.</typeparam>
19 : /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of the authentication token.</typeparam>
20 : [Serializable]
21 : public class DuplicateEventException<TAggregateRoot, TAuthenticationToken> : Exception
22 : where TAggregateRoot : IAggregateRoot<TAuthenticationToken>
23 1 : {
24 : /// <summary>
25 : /// Instantiate a new instance of <see cref="DuplicateEventException{TAggregateRoot,TAuthenticationToken}"/> with the provided identifier of the <see cref="IAggregateRoot{TAuthenticationToken}"/> that had duplicate <see cref="IEvent{TAuthenticationToken}">events</see>.
26 : /// and the <paramref name="version"/> that had more than one <see cref="IEvent{TAuthenticationToken}"/> provided.
27 : /// </summary>
28 : /// <param name="id">The identifier of the <see cref="IAggregateRoot{TAuthenticationToken}"/> that had <see cref="IEvent{TAuthenticationToken}">events</see>.</param>
29 : /// <param name="version">The version number of the duplicate <see cref="IEvent{TAuthenticationToken}">events</see></param>
30 1 : public DuplicateEventException(Guid id, int version)
31 : : base(string.Format("Eventstore gave more than one event for aggregate '{0}' of type '{1}' for version {2}", id, typeof(TAggregateRoot).FullName, version))
32 : {
33 : Id = id;
34 : AggregateType = typeof (TAggregateRoot);
35 : }
36 :
37 : /// <summary>
38 : /// The identifier of the <see cref="IAggregateRoot{TAuthenticationToken}"/> that had duplicate <see cref="IEvent{TAuthenticationToken}">events</see>..
39 : /// </summary>
40 : [DataMember]
41 : public Guid Id { get; set; }
42 :
43 : /// <summary>
44 : /// The <see cref="Type"/> of the <see cref="IAggregateRoot{TAuthenticationToken}"/> that had duplicate <see cref="IEvent{TAuthenticationToken}">events</see>..
45 : /// </summary>
46 : [DataMember]
47 : public Type AggregateType { get; set; }
48 : }
49 : }
|