本文整理汇总了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;
}
示例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;
}
示例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;
}