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


C# InMemoryRavenConfiguration.CustomizeValuesForTenant方法代码示例

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


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

示例1: CreateTenantConfiguration

		public InMemoryRavenConfiguration CreateTenantConfiguration(string tenantId)
		{
			var document = GetTenantDatabaseDocument(tenantId);
			if (document == null)
				return null;

			var config = new InMemoryRavenConfiguration
			{
				Settings = new NameValueCollection(SystemConfiguration.Settings),
			};

			SetupTenantDatabaseConfiguration(config);

			config.CustomizeValuesForTenant(tenantId);


			foreach (var setting in document.Settings)
			{
				config.Settings[setting.Key] = setting.Value;
			}
			Unprotect(document);

			foreach (var securedSetting in document.SecuredSettings)
			{
				config.Settings[securedSetting.Key] = securedSetting.Value;
			}

			var dataDir = document.Settings["Raven/DataDir"];
			if (dataDir.StartsWith("~/") || dataDir.StartsWith(@"~\"))
			{
				var baseDataPath = Path.GetDirectoryName(SystemDatabase.Configuration.DataDirectory);
				if (baseDataPath == null)
					throw new InvalidOperationException("Could not find root data path");
				config.Settings["Raven/DataDir"] = Path.Combine(baseDataPath, dataDir.Substring(2));
			}
			config.Settings["Raven/VirtualDir"] = config.Settings["Raven/VirtualDir"] + "/" + tenantId;

			config.DatabaseName = tenantId;
			config.IsTenantDatabase = true;

			config.Initialize();
			config.CopyParentSettings(SystemConfiguration);
			return config;
		}
开发者ID:urbanfly,项目名称:ravendb,代码行数:44,代码来源:HttpServer.cs

示例2: TryGetOrCreateResourceStore

		protected bool TryGetOrCreateResourceStore(string tenantId, out DocumentDatabase database)
		{
			if (ResourcesStoresCache.TryGetValue(tenantId, out database))
				return true;

			JsonDocument jsonDocument;

			using (DefaultResourceStore.DisableAllTriggersForCurrentThread())
				jsonDocument = DefaultResourceStore.Get("Raven/Databases/" + tenantId, null);

			if (jsonDocument == null ||
				jsonDocument.Metadata == null ||
				jsonDocument.Metadata.Value<bool>(Constants.RavenDocumentDoesNotExists) || 
				jsonDocument.Metadata.Value<bool>(Constants.RavenDeleteMarker))
				return false;

			var document = jsonDocument.DataAsJson.JsonDeserialization<DatabaseDocument>();

			database = ResourcesStoresCache.GetOrAddAtomically(tenantId, s =>
			{
				var config = new InMemoryRavenConfiguration
				{
					Settings = new NameValueCollection(DefaultConfiguration.Settings),
				};

				SetupTenantDatabaseConfiguration(config);

				config.CustomizeValuesForTenant(tenantId);

				var dataDir = document.Settings["Raven/DataDir"];
				if (dataDir == null)
					throw new InvalidOperationException("Could not find Raven/DataDir");
				
				foreach (var setting in document.Settings)
				{
					config.Settings[setting.Key] = setting.Value;
				}

				if (dataDir.StartsWith("~/") || dataDir.StartsWith(@"~\"))
				{
					var baseDataPath = Path.GetDirectoryName(DefaultResourceStore.Configuration.DataDirectory);
					if (baseDataPath == null)
						throw new InvalidOperationException("Could not find root data path");
					config.Settings["Raven/DataDir"] = Path.Combine(baseDataPath, dataDir.Substring(2));
				}
				config.Settings["Raven/VirtualDir"] = config.Settings["Raven/VirtualDir"] + "/" + tenantId;

				config.DatabaseName = tenantId;

				config.Initialize();
				config.CopyParentSettings(DefaultConfiguration);
				var documentDatabase = new DocumentDatabase(config);
				documentDatabase.SpinBackgroundWorkers();
				return documentDatabase;
			});
			return true;
		}
开发者ID:csainty,项目名称:ravendb,代码行数:57,代码来源:HttpServer.cs


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