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>
我想,我做一些错误的配置文件。 任何想法?
那么,什么是不按你期望的方式工作? – 2010-12-01 11:03:41
你的意思是不过滤?没有被调用或其返回值被忽略?或者是其他东西?如果你想要别人来帮助你,请更精细一点,不要让人猜测。 – 2010-12-01 13:31:57