Ninject bbv EventBroker订阅错误

时间:2012-06-18 23:21:07

标签: events ninject publish-subscribe

我正在尝试将bbv.common.EventBroker与Ninject一起使用,并且遇到了一些问题,导致连接正确。

我目前正在使用Ninject工厂创建项目,然后,由于我订阅了事件,请使用eventbroker进行订阅。但是,当调用寄存器方法时,我得到一个我根本找不到任何信息的错误。我甚至不确定错误的含义。

错误:

发生了

bbv.Common.EventBroker.Exceptions.RepeatedSubscriptionException   Message =无法为同一订户添加多个订阅处理程序方法一个主题:'Method1'。   来源= bbv.Common.EventBroker   堆栈跟踪:        at bbv.Common.EventBroker.Internals.EventTopic.ThrowIfRepeatedSubscription(Object subscriber,String handlerMethodName)        at bbv.Common.EventBroker.Internals.EventTopic.AddSubscription(Object subscriber,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(Object subscriber,Boolean register,IEventTopicHost eventTopicHost)        at bbv.Common.EventBroker.EventBroker.Register(Object item)
  InnerException:

代码:

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)
{
  ...
}

1 个答案:

答案 0 :(得分:1)

事实证明,该类的接口在其方法上具有[EventSubscription]属性。现在我知道这个错误消息确实更有意义。