温莎城堡拦截器选择器和挂钩
我正在温莎城堡做一些项目,配置文件中的拦截器挂钩有一些问题 我创建了实现 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>
我想我在配置文件中做错了什么。 有什么想法吗?
I'm doing some project in Castle Windsor and I have some problems with interceptor hook in config file
I created class that 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
}
All I want to do is to intercept methods whose name start with "Save" and hook them dynamically in the config file.
Also, in config file I have the following:
<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>
I suppose that I'm doing something wrong in config file.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论