1

I have a problem with interceptor registration. When my System.Timers.Timer Elapsed event calls a method in the same class, my interceptor for the method is not getting called. It does work if any of other methods of the class called from outside of this class. I think it seems to be the issue as described here

I have a generic solution which registers all available Interceptors using the ContainerExtensions class shown below:

public static class ContainerExtensions
{
    public static void AddInterceptor(this IWindsorContainer container, IHandler selector)
    {
        IEnumerable<Type> services = selector.ComponentModel.Services;
        foreach (var service in services)
        {
            var interceptorsSelector = (IModelInterceptorsSelector)container.Resolve(service);
            container.Kernel.ProxyFactory.AddInterceptorSelector(interceptorsSelector);
        }
    }

    public static void RegisterInterceptorSelectors(this IWindsorContainer container)
    {
        var interceptorSelectors = container.Kernel
            .GetAssignableHandlers(typeof(IModelInterceptorsSelector))
            .ToList();

        foreach (var item in interceptorSelectors)
            container.AddInterceptor(item);
    }
}

Is there any better solution other than one described in the above link? I mean do we have any solution given by Windsor team to tackle this issue in better way?

0 Answers0