本文整理汇总了C#中InMemoryRavenConfiguration.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# InMemoryRavenConfiguration.Initialize方法的具体用法?C# InMemoryRavenConfiguration.Initialize怎么用?C# InMemoryRavenConfiguration.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InMemoryRavenConfiguration
的用法示例。
在下文中一共展示了InMemoryRavenConfiguration.Initialize方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetOrCreateResourceStore
protected override bool TryGetOrCreateResourceStore(string tenantId, out IResourceStore database)
{
if (ResourcesStoresCache.TryGetValue(tenantId, out database))
return true;
var jsonDocument = DefaultDatabase.Get("Raven/Databases/" + tenantId, null);
if (jsonDocument == null)
return false;
var document = jsonDocument.DataAsJson.JsonDeserialization<DatabaseDocument>();
database = ResourcesStoresCache.GetOrAdd(tenantId, s =>
{
var config = new InMemoryRavenConfiguration
{
Settings = DefaultConfiguration.Settings,
};
config.Settings["Raven/VirtualDir"] = config.Settings["Raven/VirtualDir"] + "/" + tenantId;
foreach (var setting in document.Settings)
{
config.Settings[setting.Key] = setting.Value;
}
config.Initialize();
return new DocumentDatabase(config);
});
return true;
}
示例2: ModifyConfiguration
protected override void ModifyConfiguration(InMemoryRavenConfiguration configuration)
{
configuration.Settings["Raven/Esent/CircularLog"] = "false";
configuration.Settings["Raven/Voron/AllowIncrementalBackups"] = "true";
configuration.RunInUnreliableYetFastModeThatIsNotSuitableForProduction = false;
configuration.Initialize();
}
示例3: SubscriptionTests
public SubscriptionTests()
{
configuration = new InMemoryRavenConfiguration
{
RunInMemory = true
};
configuration.Initialize();
ravenMqServer = new RavenMqServer(configuration);
}
示例4: When_connecting_to_the_server_endpoint_will_get_error
public void When_connecting_to_the_server_endpoint_will_get_error()
{
var configuration = new InMemoryRavenConfiguration
{
RunInMemory = true
};
configuration.Initialize();
using(new RavenMqServer(configuration))
using (var c = new ClientConnection(new IPEndPoint(IPAddress.Loopback, 8181), new CaptureClientIntegration()))
{
var e = Assert.Throws<AggregateException>(() => c.Connect().Wait());
Assert.Equal("Invalid response signature from server", e.InnerException.Message);
}
}
示例5: Isolated
public void Isolated()
{
var ramDirectory = new RAMDirectory();
using (new IndexWriter(ramDirectory, new StandardAnalyzer(Version.LUCENE_29), IndexWriter.MaxFieldLength.UNLIMITED)){}
var inMemoryRavenConfiguration = new InMemoryRavenConfiguration();
inMemoryRavenConfiguration.Initialize();
;
var simpleIndex = new SimpleIndex(ramDirectory, "test", new IndexDefinition
{
Map =
@"from s in docs.Softs select new { s.f_platform, s.f_name, s.f_alias,s.f_License,s.f_totaldownload}",
Analyzers =
{
{"f_name", typeof (KeywordAnalyzer).AssemblyQualifiedName},
{"f_alias", typeof (KeywordAnalyzer).AssemblyQualifiedName},
},
Indexes =
{
{"f_platform", FieldIndexing.NotAnalyzed},
{"f_License", FieldIndexing.NotAnalyzed},
{"f_totaldownload", FieldIndexing.NotAnalyzed},
{"f_name", FieldIndexing.Analyzed},
{"f_alias", FieldIndexing.Analyzed},
},
SortOptions =
{
{"f_totaldownload", SortOptions.Int},
{"f_License", SortOptions.Int},
}
}, new MapOnlyView(), new WorkContext()
{
Configuration = inMemoryRavenConfiguration
});
var perFieldAnalyzerWrapper = simpleIndex.CreateAnalyzer(new LowerCaseKeywordAnalyzer(), new List<Action>());
var tokenStream = perFieldAnalyzerWrapper.TokenStream("f_name", new StringReader("hello Shrek"));
while (tokenStream.IncrementToken())
{
var attribute = (TermAttribute) tokenStream.GetAttribute<ITermAttribute>();
Assert.Equal("hello Shrek", attribute.Term);
}
}
示例6: CreatePrefetcher
protected PrefetcherWithContext CreatePrefetcher(Action<InMemoryRavenConfiguration> modifyConfiguration = null, Action<WorkContext> modifyWorkContext = null)
{
var configuration = new InMemoryRavenConfiguration
{
RunInMemory = true
};
configuration.Initialize();
if (modifyConfiguration != null)
modifyConfiguration(configuration);
var transactionalStorage = new TransactionalStorage(configuration, () => { }, () => { }, () => { }, () => { });
transactionalStorage.Initialize(new SequentialUuidGenerator { EtagBase = 0 }, new OrderedPartCollection<AbstractDocumentCodec>());
var workContext = new WorkContext
{
Configuration = configuration,
TransactionalStorage = transactionalStorage
};
if (modifyWorkContext != null)
modifyWorkContext(workContext);
var autoTuner = new IndexBatchSizeAutoTuner(workContext);
var prefetchingBehavior = new PrefetchingBehavior(PrefetchingUser.Indexer, workContext, autoTuner, string.Empty);
var prefetcherWithContext = new PrefetcherWithContext
{
AutoTuner = autoTuner,
Configuration = configuration,
PrefetchingBehavior = prefetchingBehavior,
TransactionalStorage = transactionalStorage,
WorkContext = workContext
};
createdPrefetchers.Add(prefetcherWithContext);
return prefetcherWithContext;
}
示例7: ConvertToRavenConfiguration
public InMemoryRavenConfiguration ConvertToRavenConfiguration()
{
var configuration = new InMemoryRavenConfiguration();
foreach (var p in ConfigurationManager.AppSettings.AllKeys.Select(k => Tuple.Create(k, ConfigurationManager.AppSettings[k])))
{
configuration.Settings.Add(p.Item1, p.Item2);
}
foreach (var key in Settings.Keys)
{
configuration.Settings.Add(key, Settings[key]);
}
configuration.Initialize();
configuration.Port = Port;
configuration.RunInMemory = RunInMemory;
configuration.DefaultStorageTypeName = DefaultStorageTypeName;
return configuration;
}
示例8: TryGetOrCreateResourceStore
protected override bool TryGetOrCreateResourceStore(string tenantId, out IResourceStore database)
{
if (ResourcesStoresCache.TryGetValue(tenantId, out database))
return true;
JsonDocument jsonDocument;
using (DefaultDatabase.DisableAllTriggersForCurrentThread())
jsonDocument = DefaultDatabase.Get("Raven/Databases/" + tenantId, null);
if (jsonDocument == null)
return false;
var document = jsonDocument.DataAsJson.JsonDeserialization<DatabaseDocument>();
database = ResourcesStoresCache.GetOrAddAtomically(tenantId, s =>
{
var config = new InMemoryRavenConfiguration
{
Settings = DefaultConfiguration.Settings,
};
foreach (var setting in document.Settings)
{
config.Settings[setting.Key] = setting.Value;
}
var dataDir = config.Settings["Raven/DataDir"];
if (dataDir == null)
throw new InvalidOperationException("Could not find Raven/DataDir");
if (dataDir.StartsWith("~/") || dataDir.StartsWith(@"~\"))
{
var baseDataPath = Path.GetDirectoryName(DefaultDatabase.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();
var documentDatabase = new DocumentDatabase(config);
documentDatabase.SpinBackgroundWorkers();
return documentDatabase;
});
return true;
}
示例9: 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;
}
示例10: ApplySettingsToConfiguration
public static void ApplySettingsToConfiguration(InMemoryRavenConfiguration configuration)
{
var settings = ServerSettings;
foreach (var setting in settings)
{
Console.WriteLine("Applying external server setting: " + setting.Key);
configuration.Settings[setting.Key] = setting.Value;
}
configuration.Initialize();
}
示例11: ApplySettingsToConfiguration
public static void ApplySettingsToConfiguration(InMemoryRavenConfiguration configuration)
{
var settings = Settings;
foreach (var setting in settings)
{
configuration.Settings[setting.Key] = setting.Value;
}
configuration.Initialize();
}