Ejemplo n.º 1
0
        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.");
        }
Ejemplo n.º 2
0
        public static void Initialize(IContainer container)
        {
            if (_documentStore != null)
            {
                return;
            }

            var documentStore = new EmbeddableDocumentStore {
                //DataDirectory = "App_Data",
                RunInMemory           = true,
                UseEmbeddedHttpServer = true
            };

            documentStore.Configuration.PluginsDirectory = System.IO.Path.Combine(AppDomain.CurrentDomain.RelativeSearchPath, "Plugins");
            documentStore.RegisterListener(new DocumentStoreListener());
            documentStore.Initialize();

            _documentStore = documentStore;

            IndexCreation.CreateIndexes(typeof(RavenConfig).Assembly, _documentStore);

            RavenProfiler.InitializeFor(_documentStore);

            using (var session = _documentStore.OpenSession()) {
                RavenQueryStatistics stats;
                session.Query <Document>().Statistics(out stats).Take(0).ToList();
                if (stats.TotalResults == 0)
                {
                    // we need to create some documents
                    var rootDoc = new Document {
                        Slug = string.Empty, Title = "Home page", Body = "<p>Welcome to this site. Go and see <a href=\"/blog\">the blog</a>.</p><p><a href=\"/about\">here</a> is the about page.</p>"
                    };
                    session.Store(rootDoc);
                    session.Store(new Document {
                        ParentId = rootDoc.Id,
                        Slug     = "about",
                        Title    = "About",
                        Body     = "This is about this site."
                    });

                    var blogDoc = new Document {
                        ParentId = rootDoc.Id,
                        Slug     = "blog",
                        Title    = "Blog",
                        Body     = "This is my blog."
                    };
                    session.Store(blogDoc);
                    session.Store(new Document {
                        ParentId = blogDoc.Id,
                        Slug     = "First",
                        Title    = "my first blog post",
                        Body     = "Hooray"
                    });

                    session.SaveChanges();
                }
            }

            container.Configure(x => x.For <IDocumentSession>().HybridHttpOrThreadLocalScoped().Use(() => _documentStore.OpenSession()));
        }
Ejemplo n.º 3
0
        private static void InitializeDocumentStore()
        {
            if (DocumentStore != null)
            {
                return;                                    // prevent misuse
            }
            DocumentStore = new EmbeddableDocumentStore
            {
                ConnectionStringName = "RavenDB"
            }.Initialize();

            TryCreatingIndexesOrRedirectToErrorPage();

            RavenProfiler.InitializeFor(DocumentStore,
                                        //Fields to filter out of the output
                                        "GoogleAnalyticsKey");
        }
Ejemplo n.º 4
0
        private static void InitializeDocumentStore()
        {
            if (DocumentStore != null)
            {
                return;                                    // prevent misuse
            }
            DocumentStore = new DocumentStore
            {
                ConnectionStringName = "RavenDB"
            }.Initialize();

            TryCreatingIndexesOrRedirectToErrorPage();

            RavenProfiler.InitializeFor(DocumentStore,
                                        //Fields to filter out of the output
                                        "Email", "HashedPassword", "AkismetKey", "GoogleAnalyticsKey", "ShowPostEvenIfPrivate",
                                        "PasswordSalt", "UserHostAddress");
        }
Ejemplo n.º 5
0
        // ReSharper disable InconsistentNaming
        protected void Application_Start()
        // ReSharper restore InconsistentNaming
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);

            ViewEngines.Engines.Clear();
            RegisterRazorViewEngine();

            RegisterRoutes(RouteTable.Routes);

            // Seed an demo data.
            SeedDocumentStore(ObjectFactory.GetInstance <IDocumentStore>());

            // Create any Facets.
            RavenFacetTags.CreateFacets(ObjectFactory.GetInstance <IDocumentStore>());

            // Wire up the RavenDb profiler.
            RavenProfiler.InitializeFor(ObjectFactory.GetInstance <IDocumentStore>());
        }
Ejemplo n.º 6
0
        public static void Start()
        {
            RavenDbStore.Initialize();

            RavenProfiler.InitializeFor(RavenDbStore.DocumentStore, "HashedPassword", "PasswordSalt");
        }
Ejemplo n.º 7
0
 private void InitializeRavenProfiler()
 {
     RavenProfiler.InitializeFor(store);
 }