コード例 #1
0
 public static void LoadAppropriateStoreRegistry(IContainer initContainer)
 {
     var store = initContainer.GetInstance<IRRConfiguration>().ContentStore;
     if (store == Configuration.Store.SqlServerStore)
     {
         var sqlAssembly = Assembly.Load("RequestReduce.SqlServer");
         initContainer.Configure(x =>
                                     {
                                         x.For(sqlAssembly.GetType("RequestReduce.SqlServer.IFileRepository"))
                                             .Use(
                                                 sqlAssembly.GetType(
                                                     "RequestReduce.SqlServer.FileRepository"));
                                         var diskStore =
                                             new ConfiguredInstance(
                                                 sqlAssembly.GetType("RequestReduce.SqlServer.SqlServerStore"));
                                         var diskCache =
                                             new ConfiguredInstance(
                                                 sqlAssembly.GetType("RequestReduce.SqlServer.DbDiskCache"));
                                         x.For<LocalDiskStore>().Singleton()
                                             .Use(diskCache);
                                         diskStore.CtorDependency<LocalDiskStore>("fileStore").Is(
                                             initContainer.GetInstance<LocalDiskStore>());
                                         diskStore.CtorDependency<IUriBuilder>("uriBuilder").Is(
                                             initContainer.GetInstance<IUriBuilder>());
                                         diskStore.CtorDependency<IReductionRepository>("reductionRepository").Is(
                                             initContainer.GetInstance<IReductionRepository>());
                                         x.For<IStore>().LifecycleIs(new RRHybridLifecycle())
                                             .Use(diskStore);
                                     });
     }
     else
         initContainer.Configure(x => x.AddRegistry<RRLocalStoreRegistry>());
 }