我有Prism Shell应用程序,有一类主要关注订阅事件的执行方法。这些事件是从我的解决方案中的单独模块触发的。
我的类是 ApplicationMenuSubscriber ,它位于我的shell应用程序中。我的外壳上装有MEFBootStrapper。我可能不想直接在shell启动时连接我的ApplicationMenuSubscriber,而是希望MEF自动选择这个类。在Prism中有没有办法做到这一点
public class ApplicationMenuSubscriber
{
private readonly IRegionManager regionManager;
private readonly IMenuService menuService;
private readonly IEventAggregator events;
[ImportingConstructor]
public ApplicationMenuSubscriber(IRegionManager regionManager, IEventAggregator events, IMenuService menuService)
{
this.regionManager = regionManager;
this.menuService = menuService;
this.events = events;
//subscribe to events
events.GetEvent<MenuEvent>().Subscribe(MenuFired);
}
private void MenuFired(ApplicationEventArgs obj)
{
//check
if (obj.Source == MenuConstants.LOGIN)
{
//log
}
}
}