我正在嘗試與Ninject一起使用bbv.common.EventBroker,並且遇到了一些問題,使事情正確連線。Ninject bbv EventBroker訂閱錯誤
我目前正在使用Ninject工廠創建一個項目,然後,由於我訂閱了事件,請使用事件經紀人進行訂閱。但是,當調用註冊方法時,我得到一個錯誤,我根本找不到任何信息。我甚至不知道錯誤的含義。
錯誤:
bbv.Common.EventBroker.Exceptions.RepeatedSubscriptionException發生 消息=無法添加同一用戶一個話題不止一個訂閱處理方法:「方法一」。 源= bbv.Common.EventBroker 堆棧跟蹤: 在bbv.Common.EventBroker.Internals.EventTopic.ThrowIfRepeatedSubscription(對象訂戶,字符串handlerMethodName) 在bbv.Common.EventBroker.Internals.EventTopic.AddSubscription(對象訂戶,MethodInfo的handlerMethod ,IHandler handler,IList`1 subscriptionMatchers) at bbv.Common.EventBroker.Internals.EventInspector.HandleSubscriber(Object subscriber,Boolean register,MethodInfo methodInfo,EventSubscriptionAttribute attr,IEventTopicHost eventTopicHost) at bbv.Common.EventBroker.Internals.EventInspector。 ProcessSubscriber(對象訂閱者,布爾寄存器,IEventTopicHost eventTopicHost) at bbv.Common.EventBroker.EventBroker.Register(Object item)
I nnerException:
代碼:
public const string Topic1 = "Topic1";
public const string Topic2 = "Topic2";
public const string Topic3 = "Topic3";
public const string Topic4 = "Topic4";
public ItemHelper(IItem item, IEventBroker eventBroker)
{
_item = item;
eventBroker.Register(this);
}
[EventSubscription(Topic1, typeof(bbv.Common.EventBroker.Handlers.Publisher))]
public void Method1(object sender, SomeArgs1 args)
{
...
}
[EventSubscription(Topic2, typeof(bbv.Common.EventBroker.Handlers.Publisher))]
public void Method2(object sender, SomeArgs2 args)
{
...
}
[EventSubscription(Topic3, typeof(bbv.Common.EventBroker.Handlers.Publisher))]
public void Method3(object sender, SomeArgs3 args)
{
...
}
[EventSubscription(Topic4, typeof(bbv.Common.EventBroker.Handlers.Publisher))]
public void Method4(object sender, SomeArgs4 args)
{
...
}