去在demo CQRS code here命令和事件處理程序是分別有線瞭如下:多種類型的用於SetHandlerInterface()與membus和IOC容器
public interface CommandHandler<in T>
{
void Handle(T command);
}
public interface EventHandler<in T>
{
void Handle(T @event);
}
bus = BusSetup.StartWith<Conservative>()
.Apply<FlexibleSubscribeAdapter>(a =>
{
a.ByInterface(typeof(IHandleEvent<>));
a.ByInterface(typeof(IHandleCommand<>));
})
.Construct();
我使用與membus鉤住在IoC容器和它的工作原理通過實現IEnumerable<object> GetAllInstances(Type desiredType)
接口與我的夢想容器,但是不像登記這個方法,我不能拆出來單獨命令和事件的界面演示:
this.Bus = BusSetup.StartWith<Conservative>()
.Apply <IoCSupport>(c =>
{
c
.SetAdapter(SimpleInjectorWiring.Instance)
.SetHandlerInterface(typeof(CommandHandler<>))
/*.SetHandlerInterface(typeof(EventHandler<>))*/;
// only CommandHandler or EventHandler can be used - not both
})
.Construct();
任何人都可以請讓我知道如果有什麼辦法在這附近,我們可以註冊任意數量的類型?