Мы используем простую оболочку вокруг специфики NSB, аналогично тому, что предлагается. Вам не нужно использовать полный IOC, но вы можете по крайней мере использовать Фабрику. Вот определение интерфейса (я могу проследить за реализацией NSB, если вам так требуется):
public interface IServiceBusAgent<T>
{
void Send(Action<T> messageConstructor);
void Send(String destination, Action<T> messageConstructor);
void Send(String destination, String correlationId, Action<T> messageConstructor);
void SendLocal(Action<T> messageConstructor);
}
public class NServiceBusAgent<T> : IServiceBusAgent<T> where T : IMessage
{
private readonly IBus bus;
public NServiceBusAgent() : this(null) { }
public NServiceBusAgent(IBus bus)
{
this.bus = bus;
}
public void Send(Action<T> messageConstructor)
{
if (null != messageConstructor)
this.bus.Send<T>(messageConstructor);
}
public void Send(String destination, Action<T> messageConstructor)
{
Send(destination, String.Empty, messageConstructor);
}
public void Send(String destination, String correlationId, Action<T> messageConstructor)
{
if (String.IsNullOrEmpty(destination))
throw new ArgumentNullException("destination");
if (null != messageConstructor)
this.bus.Send<T>(destination, correlationId, messageConstructor);
}
public void SendLocal(Action<T> messageConstructor)
{
if (null != messageConstructor)
this.bus.SendLocal<T>(messageConstructor);
}
}