예제 #1
0
        public DataAccessRegistry()
        {
            Profile("RavenDB", x=>{
                x.For<IRepository>().Use<Repository>();
                x.For<IDocumentStore>().Use(()=>{
                        var store = new EmbeddableDocumentStore {DataDirectory = "./App_Data/Database"};

                        var etagHandler = new EntityMetadataHandler();
                        store.RegisterListener(etagHandler as IDocumentConversionListener);
                        store.RegisterListener(etagHandler as IDocumentStoreListener);

                        store.Initialize();
                        return store;
                });
            });
        }
예제 #2
0
 /// <summary>
 /// Configures StructureMap to look for registries.
 /// </summary>
 /// <returns></returns>
 public static IContainer Initialize()
 {
     ObjectFactory.Initialize(x => {
         var documentStore = new EmbeddableDocumentStore { ConnectionStringName = "RavenDB" };
         documentStore.Conventions.FindTypeTagName = type => typeof(IPageModel).IsAssignableFrom(type) ? "Pages" : null;
         documentStore.RegisterListener(new StoreListener());
         documentStore.Initialize();
         IndexCreation.CreateIndexes(typeof(Documents_ByParent).Assembly, documentStore);
         x.For<IDocumentStore>().Use(documentStore);
         x.For<IDocumentSession>()
             .HybridHttpOrThreadLocalScoped()
             .Use(y =>
             {
                 var store = y.GetInstance<IDocumentStore>();
                 return store.OpenSession();
             });
         x.For<IVirtualPathResolver>().Use<VirtualPathResolver>();
         x.For<IPathResolver>().Use<PathResolver>();
         x.For<IPathData>().Use<PathData>();
         x.For<IControllerMapper>().Use<ControllerMapper>();
         x.For<ISettings>().Use<Settings>();
         x.Scan(scanner =>
         {
             scanner.AssembliesFromApplicationBaseDirectory();
             scanner.Convention<PageTypeRegistrationConvetion>();
         });
         x.For<IPageModel>().UseSpecial(y => y.ConstructedBy( r => ((MvcHandler) HttpContext.Current.Handler).RequestContext.RouteData.GetCurrentPage<IPageModel>()));
         x.For<IStructureInfo>().UseSpecial(y => y.ConstructedBy(r => ((MvcHandler)HttpContext.Current.Handler).RequestContext.RouteData.Values["StructureInfo"] as IStructureInfo));
     });
     return ObjectFactory.Container;
 }
		public static void Startup() {
		
			var sampleFrameworkDb = new EmbeddableDocumentStore {
				DataDirectory = "App_Data\\RavenDb",
				UseEmbeddedHttpServer = true
			};
			
			sampleFrameworkDb.RegisterListener(new DocumentConversionListener());
			sampleFrameworkDb.Conventions.FindClrTypeName = FindClrTypeName;
			sampleFrameworkDb.Conventions.FindTypeTagName = FindTypeTagName;
			sampleFrameworkDb.Conventions.JsonContractResolver = new DPContractResolver();
			sampleFrameworkDb.Conventions.ShouldCacheRequest = url => false;
			sampleFrameworkDb.Conventions.CustomizeJsonSerializer = serializer => {
				serializer.ContractResolver = new DPContractResolver();
				serializer.Converters.Add(new ModelCreationConverter());
			};

			sampleFrameworkDb.Initialize();
			sampleFrameworkDb.DatabaseCommands.DisableAllCaching();

			ObjectFactory.Initialize(x => {

				x.AddRegistry(new RavenDbRegistry(sampleFrameworkDb));
				x.AddRegistry(new RepositoryRegistry());

			});

		}
        public static EmbeddableDocumentStore Create(string path = null, bool initIndexes = true)
        {
            path = !string.IsNullOrWhiteSpace(path) ? path : $"{Guid.NewGuid()}";

            var documentStore = new EmbeddableDocumentStore
                                    {
                                        Configuration =
                                            {
                                                DataDirectory = path,
                                                RunInMemory = true,
                                                RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                                                MaxPageSize = 1024
                                            },
                                        RunInMemory = true
                                    };

            if (initIndexes)
            {
                lock (RavenDbInitializerLock)
                {
                    RavenDbInitializer.Initialize(documentStore).GetAwaiter().GetResult();
                }
            }

            documentStore.RegisterListener(new WaitForNonStaleResultsAsOfNowQueryListener());

            return documentStore;
        }
 public override IPersistStreams Build()
 {
     var embeddedStore = new EmbeddableDocumentStore();
     embeddedStore.Configuration.RunInMemory = true;
     embeddedStore.RegisterListener(new CheckpointNumberIncrementListener(embeddedStore));
     embeddedStore.Initialize();
     return new RavenPersistenceEngine(embeddedStore, Serializer, Options);
 }
예제 #6
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()));
        }
예제 #7
0
        protected DocumentStore GetInMemoryDocumentStore()
        {
            var documentStore = new EmbeddableDocumentStore
                {
                    RunInMemory = true
                };

            documentStore.RegisterListener(new NoStaleQueriesAllowed());
            return documentStore;
        }
예제 #8
0
		public ProjectionTests()
		{
			Now = DateTimeOffset.Now;

			DocumentStore = new EmbeddableDocumentStore { RunInMemory = true };
			DocumentStore.RegisterListener(new NoStaleQueriesAllowed());
			DocumentStore.Initialize();
			Session = DocumentStore.OpenSession();

			Setup();
		}
예제 #9
0
        private IDocumentStore CreateDocumentStore()
        {
            var store = new EmbeddableDocumentStore
            {
                Configuration =
                {
                    RunInMemory = true,
                    RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true
                }
            };

            return store.RegisterListener(new WaitForNonStaleResultsListener());
        }
예제 #10
0
 public IntegrationTest()
 {
     DocumentStore = new EmbeddableDocumentStore()
     {
         RunInMemory = true , UseEmbeddedHttpServer = true
     };
     DocumentStore.RegisterListener(new NoStaleQueries());
     DocumentStore.Initialize();
     Session = DocumentStore.OpenSession();
     UserStore = new FlexMembershipUserStore<User, Role>(Session);
     Environment = new FakeApplicationEnvironment();
     RoleProvider = new FlexRoleProvider(UserStore);
     MembershipProvider = new FlexMembershipProvider(UserStore, Environment);
 }
        internal protected IDocumentStore CreateEmbeddableStore()
        {
            EmbeddableDocumentStore store = new EmbeddableDocumentStore
            {
                Configuration =
                {
                    RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                    RunInMemory = true,
                }
            };

            store.Initialize();
            store.RegisterListener(new NoStaleQueriesListener());
            // IndexCreation.CreateIndexes(typeof(RavenUser_Roles).Assembly, store);

            return store;
        }
예제 #12
0
        /// <summary>
        /// Initializes the raven.
        /// </summary>
        /// <returns></returns>
        public static DocumentStore InitializeRaven()
        {
            var documentStore = new EmbeddableDocumentStore
            {
                ConnectionStringName = "RavenDB",
                Conventions =
                {
                    FindTypeTagName = type => typeof (IPageModel).IsAssignableFrom(type) ? "Pages" : null
                }
            };

            documentStore.RegisterListener(new StoreListener());
            documentStore.Initialize();

            IndexCreation.CreateIndexes(typeof(PageByUrl).Assembly, documentStore);

            return documentStore;
        }
예제 #13
0
    static void Main()
    {
        using (var documentStore = new EmbeddableDocumentStore
            {
                DataDirectory = "Data",
                Configuration =
                {
                    PluginsDirectory = Environment.CurrentDirectory,
                }
            })
        {
            #region RavenDBSetup

            documentStore
                .RegisterListener(new UniqueConstraintsStoreListener())
                .Initialize();

            #endregion

            BusConfiguration busConfiguration = new BusConfiguration();
            busConfiguration.EndpointName("Samples.RavenDBCustomSagaFinder");
            busConfiguration.UseSerialization<JsonSerializer>();
            busConfiguration.EnableInstallers();

            busConfiguration.UsePersistence<RavenDBPersistence>()
                .DoNotSetupDatabasePermissions() //Only required to simplify the sample setup
                .SetDefaultDocumentStore(documentStore);


            using (IBus bus = Bus.Create(busConfiguration).Start())
            {
                bus.SendLocal(new StartOrder
                {
                    OrderId = "123"
                });

                Console.WriteLine("\r\nPress any key to stop program\r\n");
                Console.ReadKey();
            }
        }
    }
예제 #14
0
 public RavenHost()
 {
     documentStore = new EmbeddableDocumentStore
     {
         DataDirectory = "Data",
         UseEmbeddedHttpServer = true,
         DefaultDatabase = "NServiceBus",
         Configuration =
         {
             Port = 32076,
             PluginsDirectory = Environment.CurrentDirectory,
             HostName = "localhost"
         }
     };
     documentStore.RegisterListener(new UniqueConstraintsStoreListener());
     documentStore.Initialize();
     //since we are hosting a fake raven server in process we need to remove it from the logging pipeline
     Trace.Listeners.Clear();
     Trace.Listeners.Add(new DefaultTraceListener());
     Console.WriteLine("Raven server started on http://localhost:32076/");
 }
예제 #15
0
        public EmbeddableDocumentStore NewStore()
        {
            store = new EmbeddableDocumentStore
            {
                Configuration =
                {
                    RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                    DefaultStorageTypeName = "munin",
                    RunInMemory = true,
                },
                UseEmbeddedHttpServer = false,
            };

            ModifyStore(store);
            ModifyConfiguration(store.Configuration);

            store.RegisterListener(new WaitForNonStaleResults());
            store.Initialize();

            CreateDefaultIndexes(store);

            return store;
        }
예제 #16
0
        public void InitaliseDocumentStore()
        {
            // Initialise the Store.
            var documentStore = new EmbeddableDocumentStore
                                {
                                    RunInMemory = true,
                                    Conventions = {DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites}
                                };
            documentStore.Initialize();

            // Force query's to wait for index's to catch up. Unit Testing only :P
            documentStore.RegisterListener(new NoStaleQueriesListener());

            // Index initialisation.
            IndexCreation.CreateIndexes(typeof(RecentPopularTags).Assembly, documentStore);

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

            // Create our Seed Data.
            CreateSeedData(documentStore);

            DocumentStore = documentStore;
        }
        /// <summary>
        ///     Configures the document store internal.
        /// </summary>
        /// <param name="documentStore">The document store.</param>
        private void ConfigureDocumentStoreInternal(EmbeddableDocumentStore documentStore)
        {
            documentStore.RegisterListener(new StoreListener(this.OnPagePublish, this.OnPageSave, this.OnPageUnPublish));
            documentStore.RegisterListener(new DeleteListener(this.OnDocumentDelete));

            IndexCreation.CreateIndexes(typeof (DefaultBrickPileBootstrapper).Assembly, documentStore);
        }
예제 #18
0
		private EmbeddableDocumentStore InitializeDocumentStore(UniqueConstraintsStoreListener listener, int port = 8079)
		{
			EmbeddableDocumentStore documentStore = new EmbeddableDocumentStore
			{
				RunInMemory = true,
				UseEmbeddedHttpServer = true,
				Configuration =
				{
					Port = port
				}
			};

			documentStore.Configuration.Catalog.Catalogs.Add(new AssemblyCatalog(typeof(UniqueConstraintsPutTrigger).Assembly));
			documentStore.RegisterListener(listener);

			documentStore.Initialize();

			return documentStore;
		}
예제 #19
0
 public void Setup()
 {
     DocumentStore = new EmbeddableDocumentStore { RunInMemory = true };
     DocumentStore.RegisterListener(new NoStaleQueriesAllowed());
     DocumentStore.Initialize();
 }
 protected override void ModifyStore(EmbeddableDocumentStore documentStore)
 {
     documentStore.RegisterListener(new AuditableEntityListener(GetCurrentUser));
 }
예제 #21
0
        private void InitaliseDocumentStore()
        {
            // Initialise the Store.
            var documentStore = new EmbeddableDocumentStore
                                {
                                    RunInMemory = true
                                };
            documentStore.Initialize();

            // Force query's to wait for index's to catch up. Unit Testing only :P
            documentStore.RegisterListener(new NoStaleQueriesListener());

            // Index initialisation.
            IndexCreation.CreateIndexes(typeof(RecentPopularTags).Assembly, documentStore);

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

            // Create our Seed Data.
            CreateSeedData(documentStore);

            // Now make sure our

            DocumentStore = documentStore;
        }