static void Main()
        {
            var container = new Container();

            container.RegisterSingle <IDynaCacheService>(new MemoryCacheService());
            container.Register(typeof(ITestClass), Cacheable.CreateType <TestClass>());

            var instance = container.GetInstance <ITestClass>();

            for (var i = 0; i < 10; i++)
            {
                // Every 2 seconds the output will change
                Console.WriteLine(instance.GetData(53));
                Thread.Sleep(500);
            }
        }
        public static void AddCacheable <TFrom, TTo>(this IServiceCollection services, ServiceLifetime serviceLifetime = ServiceLifetime.Singleton)
            where TTo : class
        {
            switch (serviceLifetime)
            {
            case ServiceLifetime.Singleton:
                services.AddSingleton(typeof(TFrom), Cacheable.CreateType <TTo>());
                break;

            case ServiceLifetime.Transient:
                services.AddTransient(typeof(TFrom), Cacheable.CreateType <TTo>());
                break;

            case ServiceLifetime.Scoped:
                services.AddScoped(typeof(TFrom), Cacheable.CreateType <TTo>());
                break;
            }
        }
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            //Add Cache Component
            container.Register(Component.For(typeof(IDynaCacheService)).ImplementedBy(typeof(MemoryCacheService)).LifestyleSingleton());

            //Auto registration all the business services
            container.Register(Classes.FromThisAssembly()
                               .BasedOn <ServiceBase>()
                               .If(t => t.Name.EndsWith("Service"))
                               .WithService.DefaultInterfaces()
                               .Configure(c => c.LifestyleSingleton()));

            //Register Email Generate Service, it should be Transient
            container.Register(Component.For <IEmailGenerateService>()
                               .ImplementedBy <RequestConfirmEmailService>().Named("RequestConfirmEmailService")
                               .LifestyleTransient());

            //Overwrite the servies's registration to use cacheable implementation
            container.Register(Component.For <ISettingService>()
                               .ImplementedBy(Cacheable.CreateType <SettingService>())
                               .IsDefault().Named("CachedSettingService").LifestyleSingleton());

            //Register HotelInfo DTO
            container.Register(Component.For <DomainInformationModel>()
                               .ImplementedBy <DomainInformationModel>().LifeStyle.HybridPerWebRequestPerThread());
            container.Register(Component.For <HotelInformationModel>()
                               .ImplementedBy <HotelInformationModel>().LifeStyle.HybridPerWebRequestPerThread());

            //Register Room Available Generate Service, it should be Transient
            container.Register(Component.For <IRequestAvailableRoomService>()
                               .ImplementedBy <RequestAvailableRoomService>().Named("RequestAvailableRoomService")
                               .LifestyleTransient());

            //Register Room Available Generate Service, it should be Transient
            container.Register(Component.For <IPlannerEventService>()
                               .ImplementedBy <PlannerEventService>().Named("PlannerEventService")
                               .LifestyleTransient());

            //Register Room Available Generate Service, it should be Transient
            container.Register(Component.For <ICenResService>()
                               .ImplementedBy <CenResService>().Named("CenResService")
                               .LifestyleTransient());
        }