我創建了自己的行爲如下:使用Unity攔截解決異常處理等交叉領域
public class BoundaryExceptionHandlingBehavior : IInterceptionBehavior
{
public IEnumerable<Type> GetRequiredInterfaces()
{
return Type.EmptyTypes;
}
public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)
{
try
{
return getNext()(input, getNext);
}
catch (Exception ex)
{
return null; //this would be something else...
}
}
public bool WillExecute
{
get { return true; }
}
}
我正確地把它設置,使預期我的行爲被擊中。但是,如果在getNext()中發生任何異常,它不會觸發我的catch塊。任何人都可以澄清爲什麼?我沒有真正想要解決這個問題,因爲有很多方法來處理異常,更多的是我不明白髮生了什麼,我想。
怎麼辦你在調試器中看到什麼時候? – SLaks 2012-03-20 03:18:05
如何爲我所有的接口實現註冊這個攔截? – TotPeRo 2016-10-14 21:46:07