当前位置: 首页>>代码示例>>C#>>正文


C# EmbeddableDocumentStore.Initialize方法代码示例

本文整理汇总了C#中Raven.Client.Embedded.EmbeddableDocumentStore.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# EmbeddableDocumentStore.Initialize方法的具体用法?C# EmbeddableDocumentStore.Initialize怎么用?C# EmbeddableDocumentStore.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Raven.Client.Embedded.EmbeddableDocumentStore的用法示例。


在下文中一共展示了EmbeddableDocumentStore.Initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        /// <summary>
        /// Configures StructureMap to look for registries.
        /// </summary>
        /// <returns></returns>
        public static IContainer Initialize()
        {
            ObjectFactory.Initialize(x => {

                var documentStore = new EmbeddableDocumentStore { ConnectionStringName = "RavenDB" };

                documentStore.Initialize();
                documentStore.Conventions.FindTypeTagName = type => typeof(IPageModel).IsAssignableFrom(type) ? "pages" : null;

                Raven.Client.MvcIntegration.RavenProfiler.InitializeFor(documentStore);

                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.For<IPageModel>().UseSpecial(y => y.ConstructedBy( r => ((MvcHandler) HttpContext.Current.Handler).RequestContext.RouteData.GetCurrentModel<IPageModel>()));
            });
            return ObjectFactory.Container;
        }
开发者ID:mattbrailsford,项目名称:BrickPile,代码行数:38,代码来源:Bootstrapper.cs

示例2: CreateKernel

        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var documentStore = new EmbeddableDocumentStore
                {
                    UseEmbeddedHttpServer = true,
                    DataDirectory = "App_Data",
                    Configuration =
                        {
                            Port = 12345,
                        },
                    Conventions =
                        {
                            CustomizeJsonSerializer = MvcApplication.SetupSerializer
                        }
                };
            documentStore.Initialize();
            var manager = new SubscriptionManager(documentStore);

            var kernel = new StandardKernel();
            kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
            kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
            kernel.Bind<IDocumentStore>()
                  .ToMethod(context => documentStore)
                  .InSingletonScope();
            RegisterServices(kernel);
            kernel.Bind<SubscriptionManager>().ToMethod(context => manager).InSingletonScope();
            return kernel;
        }
开发者ID:AndrewSwerlick,项目名称:DocumentEditor,代码行数:32,代码来源:NinjectWebCommon.cs

示例3: Should_give_documents_where_ExpirationDate_is_null_or_expirationdate_greater_than_today

        public void Should_give_documents_where_ExpirationDate_is_null_or_expirationdate_greater_than_today()
        {
            using (var documentStore = new EmbeddableDocumentStore
                                           {
                                               RunInMemory = true,
                                               Conventions =
                                                   {
                                                       DefaultQueryingConsistency =
                                                           ConsistencyOptions.QueryYourWrites
                                                   }
                                           })
            {
                documentStore.Initialize();

                using (var session = documentStore.OpenSession())
                {
                    session.Store(new Foo());
                    session.Store(new Foo());
                    session.SaveChanges();
                }
                using (var session = documentStore.OpenSession())
                {
                    var bar =
                        session.Query<Foo>()
                               .Where(foo => foo.ExpirationTime == null || foo.ExpirationTime > DateTime.Now)
                               .ToList();
                    Assert.That(bar.Count, Is.EqualTo(2));
                }
            }
        }
开发者ID:nilsml,项目名称:RavenDbEmbeddedDebug,代码行数:30,代码来源:RavenTests.cs

示例4: ShouldWork

        public void ShouldWork()
        {
            using (var _documentStore = new EmbeddableDocumentStore
                                           {
                                               RunInMemory = true,
                                               Conventions =
                                                   {
                                                       DefaultQueryingConsistency =
                                                           ConsistencyOptions.QueryYourWrites
                                                   }
                                           })
            {
                _documentStore.Initialize();

                using (var session = _documentStore.OpenSession())
                {
                    session.Store(new Foo());
                    session.Store(new Foo());
                    session.SaveChanges();
                }

                using (var session = _documentStore.OpenSession())
                {
                    var bar = session.Query<Foo>().Where(foo => foo.ExpirationTime == null || foo.ExpirationTime > DateTime.Now).ToList();
                    Assert.Equal(2, bar.Count);
                }
            }
        }
开发者ID:nilsml,项目名称:RavenDbEmbeddedDebug,代码行数:28,代码来源:QueryingUsingOr.cs

示例5: AuthenticationTest

		protected AuthenticationTest()
		{
			database::Raven.Database.Extensions.IOExtensions.DeleteDirectory("Data");
			embeddedStore = new EmbeddableDocumentStore()
			{
				Configuration = 
					{
						AnonymousUserAccessMode = database::Raven.Database.Server.AnonymousUserAccessMode.Get,
						Catalog = {Catalogs = {new AssemblyCatalog(typeof (AuthenticationUser).Assembly)}},
						DataDirectory = "Data",
						RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
						AuthenticationMode = "oauth",
						Port = 8079,
						OAuthTokenCertificate = database::Raven.Database.Config.CertGenerator.GenerateNewCertificate("RavenDB.Test")
					},
				UseEmbeddedHttpServer = true,
			};

			embeddedStore.Configuration.Initialize();
			embeddedStore.Initialize();
			store = new DocumentStore
			{
				Url = embeddedStore.Configuration.ServerUrl,
			};
			store.Initialize();
			store.JsonRequestFactory.
				EnableBasicAuthenticationOverUnsecureHttpEvenThoughPasswordsWouldBeSentOverTheWireInClearTextToBeStolenByHackers =
				true;
			foreach (DictionaryEntry de in HttpRuntime.Cache)
			{
				HttpRuntime.Cache.Remove((string)de.Key);
			}
		}
开发者ID:alwin,项目名称:ravendb,代码行数:33,代码来源:AuthorizationTest.cs

示例6: ScriptHelper

        public ScriptHelper()
        {
            var p1 = Path.Combine("Data", "System.db");
            SystemStore = new EmbeddableDocumentStore { DataDirectory = p1 };
            SystemStore.Initialize();
            System = SystemStore.OpenSession();
            SystemStore.Conventions.RegisterIdConvention<DbSetting>((db, cmds, setting) => "Settings/" + setting.Name);
            SystemStore.Conventions.RegisterIdConvention<DbScript>((db, cmds, script) => "Scripts/" + script.Name);
            try
            {
                SystemStore.DatabaseCommands.PutIndex("Settings/ByName", new IndexDefinitionBuilder<DbSetting>
                {
                    Map = settings =>
                          from setting
                              in settings
                          select new { setting.Name }
                });
                SystemStore.DatabaseCommands.PutIndex("Scripts/ByName", new IndexDefinitionBuilder<DbScript>
                {
                    Map = scripts =>
                          from script
                              in scripts
                          select new { script.Name }
                });
            }
            catch (Exception)
            {

            }

            IndexCreation.CreateIndexes(typeof(DbScript).Assembly,SystemStore);
            IndexCreation.CreateIndexes(typeof(DbSetting).Assembly, SystemStore);
        }
开发者ID:kostua16,项目名称:mycmd,代码行数:33,代码来源:ScriptHelper.cs

示例7: Startup

		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());

			});

		}
开发者ID:jthope,项目名称:SampleFramework.RavenDb,代码行数:28,代码来源:Bootstrapper.cs

示例8: InitialiseRavenDB

        private static void InitialiseRavenDB(ContainerBuilder builder)
        {
            var documentStore = new EmbeddableDocumentStore {DataDirectory = "~/DataDir"};
            documentStore.Initialize();

            builder.RegisterInstance(documentStore).As<IDocumentStore>();
        }
开发者ID:ganesum,项目名称:Blitz,代码行数:7,代码来源:Bootstrapper.cs

示例9: CanShutdown

        public void CanShutdown()
        {
            DocumentStore docStore;
            using (var store = new EmbeddableDocumentStore { UseEmbeddedHttpServer = true, RunInMemory = true })
            {
                store.Configuration.Port = 8079;

                store.Initialize();

                docStore = new DocumentStore
                {
                    Url = "http://127.0.0.1:8079/",
                    DefaultDatabase = "test"
                };
                docStore.Initialize();
                new RavenDocumentsByEntityName().Execute(docStore);

                docStore.DatabaseCommands.EnsureDatabaseExists("database");

                using (docStore.OpenSession("database"))
                {
                }
            }
            docStore.Dispose();
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:25,代码来源:DanielPilon.cs

示例10: CryptTest

        public CryptTest()
        {
            documentStore = new EmbeddableDocumentStore { RunInMemory = true };
            documentStore.Configuration.Catalog.Catalogs.Add(new AssemblyCatalog(typeof (DocumentCodec).Assembly));

            documentStore.Initialize();
        }
开发者ID:daniellangnet,项目名称:RavenCrypt,代码行数:7,代码来源:CryptTest.cs

示例11: RegisterServices

        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        public static void RegisterServices(IKernel kernel)
        {
            kernel.Bind<IApiHttpChannel>().To<ApiHttpChannel>();
            kernel.Bind<IRepresentationBuilder>().To<XmlRepresentationBuilder>();
            kernel.Bind<IRepresentationBuilder>().To<JsonRepresentationBuilder>();
            kernel.Bind<IAgentManager>().To<AgentManager>().InRequestScope();
            kernel.Bind<IPackageStore>().To<LocalPackageStore>();
            kernel.Bind<IAgentRemoteService>().To<AgentRemoteService>();

            kernel.Bind<IDocumentStore>()
                .ToMethod(ctx =>
                                {
                                    //var documentStore = new DocumentStore() { Url = "http://localhost:8080" };
                                    var documentStore = new EmbeddableDocumentStore() {DataDirectory = "App_Data/Database"};
                                    documentStore.Initialize();
                                    return documentStore;
                                }).InSingletonScope();

            kernel.Bind<IDocumentSession, DocumentSession>()
                .ToMethod(ctx =>
                                {
                                    var session = ctx.Kernel.Get<IDocumentStore>().OpenSession();
                                    session.Advanced.UseOptimisticConcurrency = true;
                                    return session as DocumentSession;

                                })
                .InRequestScope()
                .OnDeactivation((ctx, session) =>
                                    {
                                        if (session.Advanced.HasChanges)
                                        {
                                            session.SaveChanges();
                                        }
                                    });
        }
开发者ID:andrewmyhre,项目名称:DeployD,代码行数:39,代码来源:NinjectWebCommon.cs

示例12: GetAndInitializeByPath

        public static DocumentStore GetAndInitializeByPath(string path, bool enableManagementStudio, int managementStudioPort)
        {
            if (!_documentStores.ContainsKey(path))
            {
                if( enableManagementStudio )
                    NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(managementStudioPort);

                var documentStore = new EmbeddableDocumentStore 
                { 
                    DataDirectory = path,
                };

                if (enableManagementStudio)
                    documentStore.UseEmbeddedHttpServer = true;
                
                documentStore.Conventions.CustomizeJsonSerializer = s =>
                {
                    s.Converters.Add(new MethodInfoConverter());
                };

                documentStore.Initialize();

                _documentStores[path] = documentStore;
            }
            return _documentStores[path];
        }
开发者ID:JoB70,项目名称:Bifrost,代码行数:26,代码来源:DocumentStores.cs

示例13: RavenDbProvider

        static RavenDbProvider()
        {
            _documentStore = new EmbeddableDocumentStore()
            {
                DataDirectory = SpruceSettings.UserSettingsDirectory
            };

            #if DEBUG
            //_documentStore.UseEmbeddedHttpServer = true;
            //NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8081);
            #endif

            try
            {
                NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8081);
            }
            catch (Exception e)
            {
                Log.Warn(e, "RavenDb: NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8081) threw an exception");
            }

            _documentStore.Initialize();

            // Access RavenDb using http://localhost:8081. Make sure the XAP file from the lib/ravendb folder is in the Spruce.Site root.
        }
开发者ID:yetanotherchris,项目名称:spruce,代码行数:25,代码来源:RavenDbProvider.cs

示例14: Should_retrieve_all_entities_using_connection_string

        public void Should_retrieve_all_entities_using_connection_string()
        {
            using (var documentStore = new EmbeddableDocumentStore
            {
                ConnectionStringName = "Local",
                Configuration =
                {
                    RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true
                }
            })
            {
                path = documentStore.DataDirectory;

                documentStore.Initialize();

                var session1 = documentStore.OpenSession();
                session1.Store(new Company { Name = "Company 1" });
                session1.Store(new Company { Name = "Company 2" });

                session1.SaveChanges();
                var session2 = documentStore.OpenSession();
                var companyFound = session2.Advanced.DocumentQuery<Company>()
                    .WaitForNonStaleResults()
                    .ToArray();

                Assert.Equal(2, companyFound.Length);
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:28,代码来源:DocumentStoreEmbeddedGranularTests.cs

示例15: when_querying_cases_by_name_using_danish_collation

        public when_querying_cases_by_name_using_danish_collation()
        {
            var culture = new CultureInfo("da");
            Thread.CurrentThread.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;

            store = new EmbeddableDocumentStore
            {
                RunInMemory = true
            };
            store.Initialize();

            using (var session = store.OpenSession())
            {
                session.Store(new Case { Name = "bcda" });
                session.Store(new Case { Name = "dacb" });
                session.Store(new Case { Name = "daab" });
                session.Store(new Case { Name = "dacb" });
                session.Store(new Case { Name = "aacb" });
                session.Store(new Case { Name = "aaac" });
                session.Store(new Case { Name = "bcbb" });
                session.Store(new Case { Name = "acba" });
                session.Store(new Case { Name = "aaaa" });
                session.Store(new Case { Name = "dada" });
                session.SaveChanges();
            }
        }
开发者ID:larsudengaard,项目名称:ravendb,代码行数:27,代码来源:when_querying_cases_by_name.cs


注:本文中的Raven.Client.Embedded.EmbeddableDocumentStore.Initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。