我有一个 CompositePresentationEvent 列表,如下所示:
var composEvents = new List<Type>
{
typeof (GetWorkflowAnalysisDealLevelViewDataCompletedEvent),
typeof (NoDataReturnedEvent),
typeof (WorkflowDLVVisibilitiesChangedEvent),
typeof (RetrieveWorkflowDLVDataForExport),
typeof (LoadDLVTemplateEvent),
typeof (SaveDLVTemplateEvent),
typeof (PublishScreenCompositionEvent)
};
以前我会创建我的事件并使用以下内容订阅它们:
var evt1 = _eventAggregator.GetEvent<NoDataReturnedEvent>();
evt1.Subscribe(NoDataReturnedCallBack);
但是,我希望能够在循环中为列表中的每个项目执行上述操作,但是当我尝试以下操作时,它无法给出“无法解析符号 cEvent”:
foreach (var cEvent in composEvents)
{
var tmpEvt = _eventAggregator.GetEvent<cEvent>();
tmpEvt.Subscribe(NoDataReturned);
}
有人可以告诉我一个优雅的方式来实现这一目标吗?