예제 #1
0
파일: Cash.cs 프로젝트: asmorger/cash
        public static void RegisterCacheInfrastructure(IKernel kernel, ObjectCache cache, ICacheKeyRegistrationService cacheKeyRegistrationService)
        {
            kernel.Bind<ICacheKeyGenerationService>().To<CacheKeyGenerationService>();
            kernel.Bind<ICacheKeyRegistrationService>().ToConstant(cacheKeyRegistrationService);

            kernel.Bind<ObjectCache>().ToConstant(cache);
        }
예제 #2
0
파일: Cash.cs 프로젝트: asmorger/cash
        /// <summary>
        /// Adds the Cash-specific registrations to the Autofac container builder.
        /// </summary>
        /// <param name="builder">The Autofac <see cref="ContainerBuilder"/></param>
        /// <param name="cacheProvider">The <see cref="ObjectCache"/> instance to use as a cache provider.</param>
        /// <param name="registrationService">The <see cref="ICacheKeyRegistrationService"/> that contains the registrations for this solution. </param>
        public static void RegisterCacheInfrastructure(ContainerBuilder builder, ObjectCache cacheProvider, ICacheKeyRegistrationService registrationService)
        {
            builder.Register(x => cacheProvider).As<ObjectCache>().SingleInstance();
            builder.RegisterType<CacheKeyGenerationService>().As<ICacheKeyGenerationService>().SingleInstance();
            builder.Register(x => registrationService).As<ICacheKeyRegistrationService>().SingleInstance();

            builder.Register(c => new CachingInterceptor(c.Resolve<ObjectCache>(), c.Resolve<ICacheKeyGenerationService>())).InstancePerDependency();
        }
예제 #3
0
 public CacheKeyGenerationService(ICacheKeyRegistrationService cacheKeyRegistrationService)
 {
     _cacheKeyProviders = new List <ICacheKeyProvider>
     {
         new NullCacheKeyProvider(),
         new EumCacheKeyProvider(),
         new PrimitiveTypeCacheKeyProvider(),
         new UserRegisteredCacheKeyProvider(cacheKeyRegistrationService)
     }.OrderBy(x => (int)x.ExecutionOrder);
 }
예제 #4
0
        public CacheKeyGenerationService(ICacheKeyRegistrationService cacheKeyRegistrationService)
        {

            _cacheKeyProviders = new List<ICacheKeyProvider>
                                        { new NullCacheKeyProvider(),
                                          new EumCacheKeyProvider(),
                                          new PrimitiveTypeCacheKeyProvider(),
                                          new UserRegisteredCacheKeyProvider(cacheKeyRegistrationService) 
                                        }.OrderBy(x => (int)x.ExecutionOrder);
        }
예제 #5
0
        public static void RegisterDependencies(ICacheKeyRegistrationService cacheKeyRegistrationService)
        {
            var builder = new ContainerBuilder();
            builder.RegisterControllers(typeof(MvcApplication).Assembly);

            Cash.RegisterCacheInfrastructure(builder, MemoryCache.Default, cacheKeyRegistrationService);

            builder.RegisterType<RandomDataService>().As<IRandomDataService>().SingleInstance().WithDefaultCache();
            builder.RegisterType<UserService>().As<IUserService>().SingleInstance().WithDefaultCache();

            var container = builder.Build();
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
예제 #6
0
        public static void RegisterDependencies(ICacheKeyRegistrationService cacheKeyRegistrationService)
        {
            var builder = new ContainerBuilder();

            builder.RegisterControllers(typeof(MvcApplication).Assembly);

            Cash.RegisterCacheInfrastructure(builder, MemoryCache.Default, cacheKeyRegistrationService);

            builder.RegisterType <RandomDataService>().As <IRandomDataService>().SingleInstance().WithDefaultCache();
            builder.RegisterType <UserService>().As <IUserService>().SingleInstance().WithDefaultCache();

            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
 public UserRegisteredCacheKeyProvider(ICacheKeyRegistrationService cacheKeyRegistrationService)
     : base(cacheKeyRegistrationService)
 {
 }
예제 #8
0
파일: CashTests.cs 프로젝트: asmorger/cash
 public void Initialize()
 {
     Builder = new ContainerBuilder();
     Cache = A.Fake<ObjectCache>();
     RegistrationService = A.Fake<ICacheKeyRegistrationService>();
 }
예제 #9
0
 public void Initialize()
 {
     CacheKeyRegistrationService = A.Fake <ICacheKeyRegistrationService>();
     CacheKeyGenerationService   = new CacheKeyGenerationService(CacheKeyRegistrationService);
 }
예제 #10
0
 public void Initialize()
 {
     Kernel = new StandardKernel();
     Cache  = A.Fake <ObjectCache>();
     RegistrationService = A.Fake <ICacheKeyRegistrationService>();
 }
예제 #11
0
파일: Cash.cs 프로젝트: asmorger/cash
        /// <summary>
        /// Adds the Cash-specific registrations to the Autofac container builder.
        /// </summary>
        /// <param name="builder">The Autofac <see cref="ContainerBuilder"/></param>
        /// <param name="cacheProvider">The <see cref="ObjectCache"/> instance to use as a cache provider.</param>
        /// <param name="registrationService">The <see cref="ICacheKeyRegistrationService"/> that contains the registrations for this solution. </param>
        public static void RegisterCacheInfrastructure(ContainerBuilder builder, ObjectCache cacheProvider, ICacheKeyRegistrationService registrationService)
        {
            builder.Register(x => cacheProvider).As <ObjectCache>().SingleInstance();
            builder.RegisterType <CacheKeyGenerationService>().As <ICacheKeyGenerationService>().SingleInstance();
            builder.Register(x => registrationService).As <ICacheKeyRegistrationService>().SingleInstance();

            builder.Register(c => new CachingInterceptor(c.Resolve <ObjectCache>(), c.Resolve <ICacheKeyGenerationService>())).InstancePerDependency();
        }
예제 #12
0
파일: CashTests.cs 프로젝트: asmorger/cash
 public void Initialize()
 {
     Kernel = new StandardKernel();
     Cache = A.Fake<ObjectCache>();
     RegistrationService = A.Fake<ICacheKeyRegistrationService>();
 }
 protected BaseRegisteredCacheKeyProvider(ICacheKeyRegistrationService cacheKeyRegistrationService)
 {
     CacheKeyRegistrationService = cacheKeyRegistrationService;
 }
 public UserRegisteredCacheKeyProvider(ICacheKeyRegistrationService cacheKeyRegistrationService)
     : base(cacheKeyRegistrationService)
 {
 }
예제 #15
0
파일: Cash.cs 프로젝트: asmorger/cash
        public static void RegisterCacheInfrastructure(IKernel kernel, ObjectCache cache, ICacheKeyRegistrationService cacheKeyRegistrationService)
        {
            kernel.Bind <ICacheKeyGenerationService>().To <CacheKeyGenerationService>();
            kernel.Bind <ICacheKeyRegistrationService>().ToConstant(cacheKeyRegistrationService);

            kernel.Bind <ObjectCache>().ToConstant(cache);
        }
예제 #16
0
파일: CashTests.cs 프로젝트: asmorger/cash
 public void Initialize()
 {
     Builder             = new ContainerBuilder();
     Cache               = A.Fake <ObjectCache>();
     RegistrationService = A.Fake <ICacheKeyRegistrationService>();
 }
 public void Initialize()
 {
     CacheKeyRegistrationService = A.Fake<ICacheKeyRegistrationService>();
     CacheKeyGenerationService = new CacheKeyGenerationService(CacheKeyRegistrationService);
 }