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


C# RavenConfiguration.PostInit方法代码示例

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


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

示例1: GetNewServer

		protected RavenDbServer GetNewServer(int port = 8079,
			string dataDirectory = null, 
			bool runInMemory = true,
			string requestedStorage = null,
			bool deleteDirectory = true, 
			bool enableAuthentication = false)
		{
			var storageType = GetDefaultStorageType(requestedStorage);
			var ravenConfiguration = new RavenConfiguration
			{
				Port = port,
				DataDirectory = dataDirectory ?? DataDir,
				RunInMemory = storageType.Equals("esent", StringComparison.OrdinalIgnoreCase) == false && runInMemory,
				DefaultStorageTypeName = storageType,
				AnonymousUserAccessMode = enableAuthentication ? AnonymousUserAccessMode.None : AnonymousUserAccessMode.Admin
			};

			ModifyConfiguration(ravenConfiguration);

			ravenConfiguration.PostInit();

			if (ravenConfiguration.RunInMemory == false && deleteDirectory)
				IOExtensions.DeleteDirectory(ravenConfiguration.DataDirectory);

			NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port);
			var ravenDbServer = new RavenDbServer(ravenConfiguration);

			try
			{
				using (var documentStore = new DocumentStore
				{
					Url = "http://localhost:" + port,
					Conventions =
					{
						FailoverBehavior = FailoverBehavior.FailImmediately
					},
				}.Initialize())
				{
					CreateDefaultIndexes(documentStore);
				}
			}
			catch
			{
				ravenDbServer.Dispose();
				throw;
			}

			if (enableAuthentication)
			{
				EnableAuthentication(ravenDbServer.Database);
				ModifyConfiguration(ravenConfiguration);
			}

			return ravenDbServer;
		}
开发者ID:nzaugg,项目名称:ravendb,代码行数:55,代码来源:RavenTestBase.cs

示例2: GetNewServer

        protected RavenDbServer GetNewServer(int port = 8079,
            string dataDirectory = null,
            bool runInMemory = true,
            string requestedStorage = null,
            bool enableAuthentication = false,
            string activeBundles = null,
            Action<RavenDBOptions> configureServer = null,
            Action<InMemoryRavenConfiguration> configureConfig = null,
            [CallerMemberName] string databaseName = null)
        {
            databaseName = NormalizeDatabaseName(databaseName != Constants.SystemDatabase ? databaseName : null);

            checkPorts = true;
            if (dataDirectory != null)
                pathsToDelete.Add(dataDirectory);

            var storageType = GetDefaultStorageType(requestedStorage);
            var directory = dataDirectory ?? NewDataPath(databaseName == Constants.SystemDatabase ? null : databaseName);
            var ravenConfiguration = new RavenConfiguration();

            ConfigurationHelper.ApplySettingsToConfiguration(ravenConfiguration);

            ravenConfiguration.Port = port;
            ravenConfiguration.DataDirectory = Path.Combine(directory, "System");
            ravenConfiguration.RunInMemory = runInMemory;
#if DEBUG
            ravenConfiguration.RunInUnreliableYetFastModeThatIsNotSuitableForProduction = runInMemory;
#endif
            ravenConfiguration.DefaultStorageTypeName = storageType;
            ravenConfiguration.AnonymousUserAccessMode = enableAuthentication ? AnonymousUserAccessMode.None : AnonymousUserAccessMode.Admin;

            ravenConfiguration.FileSystem.DataDirectory = Path.Combine(directory, "FileSystem");
            ravenConfiguration.Encryption.UseFips = ConfigurationHelper.UseFipsEncryptionAlgorithms;

            ravenConfiguration.Settings["Raven/StorageTypeName"] = ravenConfiguration.DefaultStorageTypeName;

            if (activeBundles != null)
            {
                ravenConfiguration.Settings["Raven/ActiveBundles"] = activeBundles;
            }

            if (configureConfig != null)
                configureConfig(ravenConfiguration);
            ModifyConfiguration(ravenConfiguration);

            ravenConfiguration.PostInit();

            NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port);
            var ravenDbServer = new RavenDbServer(ravenConfiguration)
            {
                UseEmbeddedHttpServer = true,
            };
            ravenDbServer.Initialize(configureServer);
            servers.Add(ravenDbServer);

            try
            {
                using (var documentStore = new DocumentStore
                {
                    Url = "http://localhost:" + port,
                    Conventions =
                    {
                        FailoverBehavior = FailoverBehavior.FailImmediately
                    },
                    DefaultDatabase = databaseName
                }.Initialize())
                {
                    CreateDefaultIndexes(documentStore);
                }
            }
            catch
            {
                ravenDbServer.Dispose();
                throw;
            }

            if (enableAuthentication)
            {
                EnableAuthentication(ravenDbServer.SystemDatabase);
                ModifyConfiguration(ravenConfiguration);
                ravenConfiguration.PostInit();
            }

            return ravenDbServer;
        }
开发者ID:hero106wen,项目名称:ravendb,代码行数:85,代码来源:RavenTestBase.cs

示例3: GetNewServer

		protected RavenDbServer GetNewServer(int port = 8079, string dataDirectory = "Data", bool runInMemory = true, bool deleteDirectory = true)
		{
			var ravenConfiguration = new RavenConfiguration
			{
				Port = port,
				DataDirectory = dataDirectory,
				RunInMemory = runInMemory,
				AnonymousUserAccessMode = AnonymousUserAccessMode.Admin
			};

			ModifyConfiguration(ravenConfiguration);

			ravenConfiguration.PostInit();

			if (ravenConfiguration.RunInMemory == false && deleteDirectory)
				IOExtensions.DeleteDirectory(ravenConfiguration.DataDirectory);

			NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port);
			var ravenDbServer = new RavenDbServer(ravenConfiguration);

			try
			{
				using (var documentStore = new DocumentStore
				{
					Url = "http://localhost:" + port,
					Conventions =
					{
						FailoverBehavior = FailoverBehavior.FailImmediately
					},
				}.Initialize())
				{
					CreateDefaultIndexes(documentStore);
				}
			}
			catch
			{
				ravenDbServer.Dispose();
				throw;
			}
			return ravenDbServer;
		}
开发者ID:nberardi,项目名称:ravendb,代码行数:41,代码来源:RavenTestBase.cs


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