mercredi 21 octobre 2015

Can't reach an interceptor second time (Unit of Work pattern)

While implementing UoW I see strange behaviour of the methods. When I hit the page for the first time it reaches the interceptor and unit of work methods but for the second time the flow just omit the interceptor (and unit of work) and hit the business method directly. Where is the problem? I suppose it culd be somthg with the regestration of interception and uow in the conatainer thus I paste my code from this:

       public void Install(IWindsorContainer container, IConfigurationStore store)
    {

        container.Register(Component.For<IUnitOfWork>().ImplementedBy<UnitOfWork>().LifeStyle.PerWebRequest);

        container.Register(
            Component.For<UnitOfWorkInterceptor>().LifeStyle.Transient
            );

        container.Kernel.ComponentRegistered += Kernel_ComponentRegistered;

        container.AddFacility<WcfFacility>()
            .Register(
                Types.FromAssemblyNamed("WWW.Application")
                    .Where(t => t.GetInterfaces().Any(i => i.Namespace == "http://ift.tt/1XjUyVk"))

                    );
        container.Kernel.ComponentRegistered -= Kernel_ComponentRegistered;

    }

    void Kernel_ComponentRegistered(string key, Castle.MicroKernel.IHandler handler)
    {

            handler.ComponentModel.Interceptors.Add(new InterceptorReference(typeof(UnitOfWorkInterceptor)));

    }

Aucun commentaire:

Enregistrer un commentaire