//internal class ServiceInstaller : IWindsorInstaller //{ // //public void Install(IWindsorContainer container, IConfigurationStore store) // //{ // // container.Register(Component.For<Shopper>().LifeStyle.Transient); // // container.Register(Component.For<ICreditCard>().ImplementedBy<MasterCard>().LifeStyle.Transient); // //} // public void Install(IWindsorContainer container, IConfigurationStore store) // { // container.Register(Component.For<Repository>().LifeStyle.Transient); // container.Register(Component.For<IRepository>().ImplementedBy<Repository>().LifeStyle.Transient); // } //} private static void Kernel_ComponentRegistered(string key, IHandler handler) { //Do not intercept repositories. if (UnitOfWorkProvider.IsRepositoryClass(handler.ComponentModel.Implementation)) { return; } //Intercept all methods of classes those have at least one method that has UnitOfWork attribute. foreach (var method in handler.ComponentModel.Implementation.GetMethods()) { if (UnitOfWorkProvider.HasUnitOfWorkAttribute(method)) { //handler.ComponentModel.Interceptors.Add(new InterceptorReference(typeof(UnitOfWorkInterceptor))); return; } } }