ここでデモ CQRS コードを調べると、コマンドとイベント ハンドラーは以下のように個別に接続されます。
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();
任意の数のタイプに登録できるように、これを回避する方法があるかどうか誰かに教えてもらえますか?