Created
July 15, 2011 10:25
-
-
Save jimitndiaye/1084446 to your computer and use it in GitHub Desktop.
Generic EventMessage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Wraps an <see cref = "IEvent">event</see> | |
/// to be transportable by NServiceBus. | |
/// </summary> | |
[Serializable] | |
[DataContract(Namespace = MessageNamespace)] | |
public class EventMessage<TEvent> : EventMessage, IEventMessage<TEvent> where TEvent : class | |
{ | |
public EventMessage(IPublishedEvent<TEvent> @event) : base(@event) | |
{ | |
Contract.Requires<ArgumentNullException>(@event != null, "event"); | |
Contract.Requires<ArgumentException>(@event.Payload != null); | |
} | |
#region Implementation of IEventMessage | |
/// <summary> | |
/// Gets or sets transported event. | |
/// </summary> | |
new public IPublishedEvent<TEvent> Payload | |
{ | |
get { return (IPublishedEvent<TEvent>) base.Payload; } | |
} | |
#endregion | |
} | |
[Serializable] | |
[DataContract(Namespace = MessageNamespace)] | |
public class EventMessage : MessageBase, IEventMessage | |
{ | |
public EventMessage(IPublishableEvent @event) | |
{ | |
Payload = @event; | |
} | |
[DataMember(Order = 1)] | |
public IPublishableEvent Payload { get; private set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment