Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generic EventMessage
/// <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
You can’t perform that action at this time.