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="IEvent{TAuthenticationToken}"/> had not <see cref="IEvent{TAuthenticationToken}.Id"/> set.
17 : /// </summary>
18 : [Serializable]
19 : public class AggregateOrEventMissingIdException : Exception
20 1 : {
21 : /// <summary>
22 : /// Instantiate a new instance of <see cref="AggregateOrEventMissingIdException"/> with the <see cref="Type"/> of the <see cref="IEvent{TAuthenticationToken}"/> and <see cref="IAggregateRoot{TAuthenticationToken}"/>.
23 : /// The <paramref name="eventType"/> that was trying to be saved on an <paramref name="aggregateType"/>.
24 : /// </summary>
25 : /// <param name="aggregateType">The <see cref="Type"/> of the <see cref="IAggregateRoot{TAuthenticationToken}"/> that the <see cref="IEvent{TAuthenticationToken}"/> was trying to be saved on.</param>
26 : /// <param name="eventType">The <see cref="Type"/> of the <see cref="IEvent{TAuthenticationToken}"/> that was trying to be saved.</param>
27 1 : public AggregateOrEventMissingIdException(Type aggregateType, Type eventType)
28 : : base(string.Format("An event of type {0} tried to be saved from {1} but no id was set on either", eventType.FullName, aggregateType.FullName))
29 : {
30 : AggregateType = aggregateType;
31 : EventType = eventType;
32 : }
33 :
34 : /// <summary>
35 : /// The <see cref="Type"/> of the <see cref="IAggregateRoot{TAuthenticationToken}"/> that the <see cref="IEvent{TAuthenticationToken}"/> was trying to be saved on.
36 : /// </summary>
37 : [DataMember]
38 : public Type AggregateType { get; set; }
39 :
40 : /// <summary>
41 : /// The <see cref="Type"/> of the <see cref="IEvent{TAuthenticationToken}"/> that was trying to be saved.
42 : /// </summary>
43 : [DataMember]
44 : public Type EventType { get; set; }
45 : }
46 : }
|