2010-12-01 82 views
1

我做在溫莎城堡的一些項目,我有一些問題的攔截鉤在配置文件 我創建類,impements IProxyGenerationHook溫莎城堡攔截器選擇和掛鉤

public class LoggingProxyGenerationHook : IProxyGenerationHook 
{ 

    #region IProxyGenerationHook Members 

    public void MethodsInspected() 
    { 
     //throw new Exception("The method or operation is not implemented."); 
    } 

    public void NonVirtualMemberNotification(Type type, System.Reflection.MemberInfo memberInfo) 
    { 
     //throw new Exception("The method or operation is not implemented."); 
    } 

    public bool ShouldInterceptMethod(Type type, System.Reflection.MethodInfo methodInfo) 
    { 
     return methodInfo.Name.StartsWith("Save", StringComparison.Ordinal); 
    } 

    #endregion 
} 

所有我想要做的就是攔截其名稱以「Save」開頭的方法並將它們動態掛接在配置文件中。 此外,在配置文件中我有以下幾點:

<component id="LoggingAspect" type="DynamicInterceptor.LoggingAspect, DynamicInterceptor"></component> 
<component id="LoggingProxyGenerationHook" type="DynamicInterceptor.LoggingProxyGenerationHook, DynamicInterceptor"></component> 
<component id="TestClass1" type="TestClasses.TestClass1, TestClasses"> 
<interceptors hook ="${LoggingProxyGenerationHook}"> 
<interceptor>${LoggingAspect}</interceptor> 
</interceptors> 
</component> 

我想,我做一些錯誤的配置文件。 任何想法?

+1

那麼,什麼是不按你期望的方式工作? – 2010-12-01 11:03:41

+1

你的意思是不過濾?沒有被調用或其返回值被忽略?或者是其他東西?如果你想要別人來幫助你,請更精細一點,不要讓人猜測。 – 2010-12-01 13:31:57

回答