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