我正在温莎城堡做一些项目,我在配置文件中遇到了一些拦截器钩子问题,我创建了一个类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>
我想我在配置文件中做错了什么。有任何想法吗?