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.Commands;
11 : using Cqrs.Events;
12 :
13 : namespace Cqrs.Azure.ServiceBus
14 : {
15 : /// <summary>
16 : /// Serialises <see cref="IEvent{TAuthenticationToken}">events</see> and <see cref="ICommand{TAuthenticationToken}">commands</see>.
17 : /// </summary>
18 : /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of the authentication token.</typeparam>
19 : public interface IMessageSerialiser<TAuthenticationToken>
20 : {
21 : /// <summary>
22 : /// Serialise the provided <paramref name="event"/>.
23 : /// </summary>
24 : /// <typeparam name="TEvent">The <see cref="Type"/> of the <see cref="IEvent{TAuthenticationToken}"/> being serialised.</typeparam>
25 : /// <param name="event">The <see cref="IEvent{TAuthenticationToken}"/> being serialised.</param>
26 : /// <returns>A <see cref="string"/> representation of the provided <paramref name="event"/>.</returns>
27 1 : string SerialiseEvent<TEvent>(TEvent @event)
28 : where TEvent : IEvent<TAuthenticationToken>;
29 :
30 : /// <summary>
31 : /// Serialise the provided <paramref name="command"/>.
32 : /// </summary>
33 : /// <typeparam name="TCommand">The <see cref="Type"/> of the <see cref="ICommand{TAuthenticationToken}"/> being serialised.</typeparam>
34 : /// <param name="command">The <see cref="ICommand{TAuthenticationToken}"/> being serialised.</param>
35 : /// <returns>A <see cref="string"/> representation of the provided <paramref name="command"/>.</returns>
36 1 : string SerialiseCommand<TCommand>(TCommand command)
37 : where TCommand : ICommand<TAuthenticationToken>;
38 :
39 : /// <summary>
40 : /// Deserialise the provided <paramref name="event"/> from its <see cref="string"/> representation.
41 : /// </summary>
42 : /// <param name="event">A <see cref="string"/> representation of an <see cref="IEvent{TAuthenticationToken}"/> to deserialise.</param>
43 1 : IEvent<TAuthenticationToken> DeserialiseEvent(string @event);
44 :
45 : /// <summary>
46 : /// Deserialise the provided <paramref name="command"/> from its <see cref="string"/> representation.
47 : /// </summary>
48 : /// <param name="command">A <see cref="string"/> representation of an <see cref="ICommand{TAuthenticationToken}"/> to deserialise.</param>
49 1 : ICommand<TAuthenticationToken> DeserialiseCommand(string command);
50 : }
51 : }
|