In the unobtrusive NServiceBus sample it explains how to map your inbound messages to ICommand / IEvent / IMessage in the endpoint configuration as follows:
.DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith("Commands"))
.DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith("Events"))
.DefiningMessagesAs(t => t.Namespace == "Messages")
But what about the following example, where I'd like to create a marker interface and have all my events implement it:
public interface IAmSomeEvent
{
}
public class SomethingImportantHappenned : IAmSomeEvent
{
public string blah { get; set; }
}
and then do something like this:
.DefiningEventsAs(t => t.GetInterfaces().Contains(typeof(IAmSomeEvent)))
But the problem with this is it doesn't work (NSB does not map this to IEvent).
I can kind of see why this doesn't work as NSB is just receiving a stream of json (or XML) and so it doesn't really care that the original type happens to implement some interface or other. But it would be a very nice feature.
Does anyone have any suggestions about how to achieve this?
Many thanks