コード例 #1
0
ファイル: RavenDbRegistry.cs プロジェクト: neiz/RavenOverflow
        public RavenDbRegistry(string connectionStringName)
        {
            For<IDocumentStore>()
                .Singleton()
                .Use(x =>
                     {
                         var documentStore = new DocumentStore {ConnectionStringName = connectionStringName};
                         documentStore.InitializeWithDefaults();

                         // Create any Facets.
                         RavenFacetTags.CreateFacets(documentStore);

                         // Wire up the RavenDb profiler.
                         // This is -very- MVC specific, of course. You wouldn't find this in the Tests.
                         RavenProfiler.InitializeFor(documentStore);

                         return documentStore;
                     }
                )
                .Named("RavenDB Document Store.");

            For<IDocumentSession>()
                .HttpContextScoped()
                .Use(x =>
                     {
                         var documentStore = x.GetInstance<IDocumentStore>();
                         return documentStore.OpenSession();
                     })
                .Named("RavenDb Session -> per Http Request.");
        }