我們要觸發事件,與保存在SQL Server通用EventAggregator?
在SQL Server,你會發現ApplicationExitRequestEvent 事件名稱當我們點擊菜單鍵,我們將從菜單項
Type t = Type.GetType(SelectedMenu.View + "," + "AssemblyName");
var obj = Activator.CreateInstance(t);
if (t != null)
{
//Working firing Event with className
EventAggregator.GetEvent<ApplicationExitRequestEvent>().Publish(null);
//Generic?
EventAggregator.GetEvent<???>().Publish(null);
}
得到字符串
我可以做嗎? 使用PRISM和MVVM - WPF - .NET 4.0
請參閱[此問題](http://stackoverflow.com/questions/232535/how-to-use-reflection-to-call-generic-method)瞭解如何使用反射調用通用方法。儘管性能是一個問題,但這可能不是最佳做法。 – 2012-03-08 10:01:42
thx。 'MethodInfo method = EventAggregator.GetType()。GetMethod(「GetEvent」); MethodInfo generic = method.MakeGenericMethod(typeof(ApplicationExitRequestEvent)); generic.Invoke(this,null);' 不起作用。任何想法? – 2012-03-08 14:53:07
對象不等於目標對象?! – 2012-03-08 15:06:51