Question

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?

Was it helpful?

Solution

Works for me. (Windsor/Core 2.5.2)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top