Beispiel #1
0
        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);
        }
Beispiel #2
0
        /// <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();
        }
Beispiel #3
0
 public CacheKeyGenerationService(ICacheKeyRegistrationService cacheKeyRegistrationService)
 {
     _cacheKeyProviders = new List <ICacheKeyProvider>
     {
         new NullCacheKeyProvider(),
         new EumCacheKeyProvider(),
         new PrimitiveTypeCacheKeyProvider(),
         new UserRegisteredCacheKeyProvider(cacheKeyRegistrationService)
     }.OrderBy(x => (int)x.ExecutionOrder);
 }
        public CacheKeyGenerationService(ICacheKeyRegistrationService cacheKeyRegistrationService)
        {

            _cacheKeyProviders = new List<ICacheKeyProvider>
                                        { new NullCacheKeyProvider(),
                                          new EumCacheKeyProvider(),
                                          new PrimitiveTypeCacheKeyProvider(),
                                          new UserRegisteredCacheKeyProvider(cacheKeyRegistrationService) 
                                        }.OrderBy(x => (int)x.ExecutionOrder);
        }
Beispiel #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));
        }
Beispiel #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)
 {
 }
Beispiel #8
0
 public void Initialize()
 {
     Builder = new ContainerBuilder();
     Cache = A.Fake<ObjectCache>();
     RegistrationService = A.Fake<ICacheKeyRegistrationService>();
 }
Beispiel #9
0
 public void Initialize()
 {
     CacheKeyRegistrationService = A.Fake <ICacheKeyRegistrationService>();
     CacheKeyGenerationService   = new CacheKeyGenerationService(CacheKeyRegistrationService);
 }
Beispiel #10
0
 public void Initialize()
 {
     Kernel = new StandardKernel();
     Cache  = A.Fake <ObjectCache>();
     RegistrationService = A.Fake <ICacheKeyRegistrationService>();
 }
Beispiel #11
0
        /// <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();
        }
Beispiel #12
0
 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)
 {
 }
Beispiel #15
0
        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);
        }
Beispiel #16
0
 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);
 }