C# 温莎城堡拦截器选择器和挂钩
我在温莎城堡做一些项目,我在配置文件中遇到了一些拦截钩子的问题 我创建了一个类,该类包含IProxyGenerationHookC# 温莎城堡拦截器选择器和挂钩,c#,castle-windsor,interceptor,castle-dynamicproxy,C#,Castle Windsor,Interceptor,Castle Dynamicproxy,我在温莎城堡做一些项目,我在配置文件中遇到了一些拦截钩子的问题 我创建了一个类,该类包含IProxyGenerationHook: public class LoggingProxyGenerationHook : IProxyGenerationHook { #region IProxyGenerationHook Members public void MethodsInspected() { //throw new Exception("The
:
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>
${LoggingAspect}
我想我在配置文件中做错了什么。
有什么想法吗?那么,什么东西没有按您预期的方式工作?什么意思是没有过滤?是否未调用或忽略其返回值?还是别的什么?如果你想有人帮助你,就要说得更详细些,不要让别人猜。@nikolavas:说这话不公平。Krzysztof在Castle上花费了大量的空闲时间和精力,甚至对Castle文档进行了大量改进。那么,什么东西没有按您预期的方式工作呢?什么意思是没有过滤?是否未调用或忽略其返回值?还是别的什么?如果你想有人帮助你,就要说得更详细些,不要让别人猜。@nikolavas:说这话不公平。Krzysztof在Castle上花费了大量的空闲时间和精力,甚至改进了Castle文档。