我正在使用AssemblyResolve。這是我的代碼第一,然後我的問題如下:將自己的參數發送給事件處理程序?
var a = AppDomain.CurrentDomain;
a.AssemblyResolve += new ResolveEventHandler(HandleIt);
Private Assembly HandleIt(object sender, ResolveEventArgs args){
//Does stuff, returns an assembly
}
因此,我將HandleIt添加到我的AssemblyResolve事件。我怎樣才能把它添加到該事件,並傳遞一個參數,它像:
a.AssemblyResolve += new ResolveEventHandler(HandleIt(AnArgument));
這是扔我了,因爲HandleIt接受參數,但是當它被添加到AssemblyResolve事件沒有被explicetly通過。我希望是這樣的:
a.AssemblyResolve += new ResolveEventHandler(HandleIt(aSender,someArgs));
所以,是的,我只是希望能夠將它添加到我的AssemblyResolve事件時,另外一個參數發送給我的HandleIt功能。
希望有道理,謝謝。
附錄:
if(aBool){
a.AssemblyResolve += new ResolveEventHandler(HandleA);
}
else{
a.AssemblyResolve += new ResolveEventHandler(HandleB);
}
HandleA(object sender, ResolveEventArgs args){
Handle(true);
}
HandleB(object sender, ResolveEventArgs args){
Handle(false);
}
Handle(bool isA){
}
航班嗎
if(aBool){
a.AssemblyResolve += (object s, ResolveEventArgs a) => Handle(s,a,true);
}
else{
a.AssemblyResolve += (object s, ResolveEventArgs a) => Handle(s,a,false);
}
Handle(object sender, ResolveEventArgs args, bool isA){
}
你不需要的,如果(aBool)在lambda版本,你可以簡單地say'a.AssemblyResolve + =(對象S,ResolveEventArgs一)= >拉手(S,A,aBool);'或曾經的說法應該是什麼 – 2011-06-26 14:01:17