本文整理汇总了C#中Raven.Client.Embedded.EmbeddableDocumentStore.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# EmbeddableDocumentStore.Dispose方法的具体用法?C# EmbeddableDocumentStore.Dispose怎么用?C# EmbeddableDocumentStore.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Raven.Client.Embedded.EmbeddableDocumentStore
的用法示例。
在下文中一共展示了EmbeddableDocumentStore.Dispose方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunningInEmbeddedMode
public void RunningInEmbeddedMode()
{
#region running_in_embedded_mode
var documentStore = new EmbeddableDocumentStore { DataDirectory = "path/to/database/directory" };
documentStore.Initialize();
#endregion
documentStore.Dispose();
}
示例2: SupportsEmbeddedHttpServer
public dynamic SupportsEmbeddedHttpServer()
{
var dirname = Guid.NewGuid().ToString("N");
try
{
int ravenPort = 8181;
NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenPort);
var documentStore = new EmbeddableDocumentStore
{
DataDirectory = "~/App_Data/" + dirname,
UseEmbeddedHttpServer = true,
Configuration = { Port = ravenPort }
};
documentStore.Initialize();
documentStore.Dispose();
return new
{
success = true
};
}
catch (Exception ex)
{
return new
{
success = false,
error = ex.Message
};
}
finally
{
try
{
Directory.Delete(HttpContext.Current.Server.MapPath("~/App_Data/" + dirname), true);
}
catch (Exception ex)
{
var x = ex.Message;
}
}
}
示例3: IsEmbeddable
public dynamic IsEmbeddable()
{
var dirname = Guid.NewGuid().ToString("N");
try
{
var documentStore = new EmbeddableDocumentStore
{
DataDirectory = "~/App_Data/" + dirname,
UseEmbeddedHttpServer = false
};
documentStore.Initialize();
documentStore.Dispose();
return new
{
success = true
};
}
catch (Exception ex)
{
return new
{
success = false,
error = ex.Message
};
}
finally
{
try
{
Directory.Delete(HttpContext.Current.Server.MapPath("~/App_Data/" + dirname), true);
}
catch (Exception ex)
{
var x = ex.Message;
}
}
}
示例4: NewDocumentStore
//.........这里部分代码省略.........
bool runInMemory = true,
string requestedStorage = null,
ComposablePartCatalog catalog = null,
string dataDir = null,
bool enableAuthentication = false,
string activeBundles = null,
int? port = null,
AnonymousUserAccessMode anonymousUserAccessMode = AnonymousUserAccessMode.Admin,
Action<EmbeddableDocumentStore> configureStore = null,
[CallerMemberName] string databaseName = null,
IEnumerable<AbstractIndexCreationTask> indexes = null,
IEnumerable<AbstractTransformerCreationTask> transformers = null,
IEnumerable<IEnumerable> seedData = null,
bool noStaleQueries = false,
DocumentConvention conventions = null)
{
databaseName = NormalizeDatabaseName(databaseName);
var storageType = GetDefaultStorageType(requestedStorage);
var dataDirectory = dataDir ?? NewDataPath(databaseName);
var documentStore = new EmbeddableDocumentStore
{
UseEmbeddedHttpServer = port.HasValue,
Conventions = conventions ?? new DocumentConvention()
};
ConfigurationHelper.ApplySettingsToConfiguration(documentStore.Configuration);
documentStore.Configuration.DefaultStorageTypeName = storageType;
documentStore.Configuration.DataDirectory = Path.Combine(dataDirectory, "System");
documentStore.Configuration.RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true;
documentStore.Configuration.RunInMemory = storageType.Equals("esent", StringComparison.OrdinalIgnoreCase) == false && runInMemory;
documentStore.Configuration.Port = port ?? 8079;
documentStore.Configuration.AnonymousUserAccessMode = anonymousUserAccessMode;
documentStore.Configuration.FileSystem.DataDirectory = Path.Combine(dataDirectory, "FileSystem");
documentStore.Configuration.Encryption.UseFips = ConfigurationHelper.UseFipsEncryptionAlgorithms;
if (activeBundles != null)
{
documentStore.Configuration.Settings["Raven/ActiveBundles"] = activeBundles;
}
if (catalog != null)
{
documentStore.Configuration.Catalog.Catalogs.Add(catalog);
}
try
{
if (configureStore != null)
{
configureStore(documentStore);
}
ModifyStore(documentStore);
ModifyConfiguration(documentStore.Configuration);
documentStore.Configuration.PostInit();
documentStore.Initialize();
if (enableAuthentication)
{
EnableAuthentication(documentStore.SystemDatabase);
}
CreateDefaultIndexes(documentStore);
if (indexes != null)
{
ExecuteIndexes(indexes, documentStore);
}
if (noStaleQueries)
{
documentStore.Listeners.RegisterListener(new NoStaleQueriesListener());
}
if (transformers != null)
{
ExecuteTransformers(transformers, documentStore);
}
if (seedData != null)
{
StoreSeedData(seedData, documentStore);
}
return documentStore;
}
catch
{
// We must dispose of this object in exceptional cases, otherwise this test will break all the following tests.
documentStore.Dispose();
throw;
}
finally
{
stores.Add(documentStore);
}
}
示例5: NewDocumentStore
public EmbeddableDocumentStore NewDocumentStore(
bool deleteDirectory = true,
string requestedStorage = null,
ComposablePartCatalog catalog = null,
bool deleteDirectoryOnDispose = true)
{
path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(DocumentStoreServerTests)).CodeBase);
path = Path.Combine(path, "TestDb").Substring(6);
string defaultStorageType = GetDefaultStorageType(requestedStorage);
var documentStore = new EmbeddableDocumentStore
{
Configuration =
{
DefaultStorageTypeName = defaultStorageType,
DataDirectory = path,
RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
RunInMemory = false,
Port = 8079
}
};
if (catalog != null)
documentStore.Configuration.Catalog.Catalogs.Add(catalog);
try
{
ModifyStore(documentStore);
ModifyConfiguration(documentStore.Configuration);
if (deleteDirectory)
IOExtensions.DeleteDirectory(path);
documentStore.Initialize();
CreateDefaultIndexes(documentStore);
if (deleteDirectoryOnDispose)
documentStore.Disposed += ClearDatabaseDirectory;
return documentStore;
}
catch
{
// We must dispose of this object in exceptional cases, otherwise this test will break all the following tests.
documentStore.Dispose();
throw;
}
finally
{
stores.Add(documentStore);
}
}
示例6: NewDocumentStore
public EmbeddableDocumentStore NewDocumentStore(
bool runInMemory = true,
string requestedStorage = null,
ComposablePartCatalog catalog = null,
bool deleteDirectory = true,
bool deleteDirectoryOnDispose = true,
bool enableAuthentication = false)
{
path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(RavenTestBase)).CodeBase);
if (path.StartsWith(@"file:\", StringComparison.InvariantCultureIgnoreCase))
path = path.Substring(6);
path = Path.Combine(path, Path.GetFileName(Path.GetDirectoryName(DataDir)));
var storageType = GetDefaultStorageType(requestedStorage);
var documentStore = new EmbeddableDocumentStore
{
Configuration =
{
DefaultStorageTypeName = storageType,
DataDirectory = path,
RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
RunInMemory = storageType.Equals("esent", StringComparison.OrdinalIgnoreCase) == false && runInMemory,
Port = 8079
}
};
if (catalog != null)
documentStore.Configuration.Catalog.Catalogs.Add(catalog);
try
{
ModifyStore(documentStore);
ModifyConfiguration(documentStore.Configuration);
if (deleteDirectory)
IOExtensions.DeleteDirectory(path);
documentStore.Initialize();
if (enableAuthentication)
{
EnableAuthentication(documentStore.DocumentDatabase);
ModifyConfiguration(documentStore.Configuration);
}
CreateDefaultIndexes(documentStore);
if (deleteDirectoryOnDispose)
documentStore.Disposed += ClearDatabaseDirectory;
return documentStore;
}
catch
{
// We must dispose of this object in exceptional cases, otherwise this test will break all the following tests.
documentStore.Dispose();
throw;
}
finally
{
stores.Add(documentStore);
}
}
示例7: NewDocumentStore
public EmbeddableDocumentStore NewDocumentStore(
bool runInMemory = true,
string requestedStorage = null,
ComposablePartCatalog catalog = null,
string dataDir = null,
bool enableAuthentication = false)
{
var storageType = GetDefaultStorageType(requestedStorage);
var documentStore = new EmbeddableDocumentStore
{
Configuration =
{
DefaultStorageTypeName = storageType,
DataDirectory = dataDir ?? NewDataPath(),
RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
RunInMemory = storageType.Equals("esent", StringComparison.OrdinalIgnoreCase) == false && runInMemory,
Port = 8079
}
};
if (catalog != null)
documentStore.Configuration.Catalog.Catalogs.Add(catalog);
try
{
ModifyStore(documentStore);
ModifyConfiguration(documentStore.Configuration);
documentStore.Initialize();
if (enableAuthentication)
{
EnableAuthentication(documentStore.DocumentDatabase);
ModifyConfiguration(documentStore.Configuration);
}
CreateDefaultIndexes(documentStore);
return documentStore;
}
catch
{
// We must dispose of this object in exceptional cases, otherwise this test will break all the following tests.
documentStore.Dispose();
throw;
}
finally
{
stores.Add(documentStore);
}
}
示例8: NewDocumentStore
public EmbeddableDocumentStore NewDocumentStore(
bool runInMemory = true,
string requestedStorage = null,
ComposablePartCatalog catalog = null,
string dataDir = null,
bool enableAuthentication = false,
string activeBundles = null,
int? port = null,
AnonymousUserAccessMode anonymousUserAccessMode = AnonymousUserAccessMode.Admin,
Action<EmbeddableDocumentStore> configureStore = null,
[CallerMemberName] string databaseName = null)
{
databaseName = NormalizeDatabaseName(databaseName);
var storageType = GetDefaultStorageType(requestedStorage);
var dataDirectory = dataDir ?? NewDataPath(databaseName);
var documentStore = new EmbeddableDocumentStore
{
UseEmbeddedHttpServer = port.HasValue,
Configuration =
{
DefaultStorageTypeName = storageType,
DataDirectory = Path.Combine(dataDirectory, "System"),
FileSystemDataDirectory = Path.Combine(dataDirectory, "FileSystem"),
RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
RunInMemory = storageType.Equals("esent", StringComparison.OrdinalIgnoreCase) == false && runInMemory,
Port = port == null ? 8079 : port.Value,
UseFips = SettingsHelper.UseFipsEncryptionAlgorithms,
AnonymousUserAccessMode = anonymousUserAccessMode,
}
};
if (activeBundles != null)
{
documentStore.Configuration.Settings["Raven/ActiveBundles"] = activeBundles;
}
if (catalog != null)
documentStore.Configuration.Catalog.Catalogs.Add(catalog);
try
{
if (configureStore != null)
configureStore(documentStore);
ModifyStore(documentStore);
ModifyConfiguration(documentStore.Configuration);
documentStore.Configuration.PostInit();
documentStore.Initialize();
if (enableAuthentication)
{
EnableAuthentication(documentStore.DocumentDatabase);
}
CreateDefaultIndexes(documentStore);
return documentStore;
}
catch
{
// We must dispose of this object in exceptional cases, otherwise this test will break all the following tests.
documentStore.Dispose();
throw;
}
finally
{
stores.Add(documentStore);
}
}
示例9: Must_have_a_document_store
public void Must_have_a_document_store()
{
// DocumentStores are at the core of RavenDB.
// They allow you to access the database instance
// of the application.
// DocumentStores come in three flavors:
// - Remote
// - Embedded
// - In Memory
// This is a RavenDB running in memory
var documentStore = new EmbeddableDocumentStore {
RunInMemory = true
}
// You need to initialize your documentstore
// after you set the configuration above.
.Initialize();
// Remote example
// var documentStore = new DocumentStore {
// ConnectionStringName = "RavenDb"
// }.Initialize();
// Embedded example
// var documentStore = new EmbeddableDocumentStore {
// ConnectionStringName = "RavenDb"
// }
documentStore.Should()
.NotBeNull();
// remember to dispose your document store
// or let the application shutdown dispose it
documentStore.Dispose();
}
示例10: Main
private static void Main()
{
// Initialize the database and create indexes
var documentStore = new EmbeddableDocumentStore {
UseEmbeddedHttpServer = true,
#if DEBUG
RunInMemory = true
#endif
};
_documentStore = documentStore;
documentStore.SetStudioConfigToAllowSingleDb();
documentStore.Configuration.AnonymousUserAccessMode = AnonymousUserAccessMode.All;
documentStore.Configuration.Settings.Add("Raven/ActiveBundles", "Expiration");
documentStore.Configuration.Settings.Add("Raven/Expiration/DeleteFrequencySeconds", "10");
documentStore.Initialize();
IndexCreation.CreateIndexes(typeof(Program).Assembly, documentStore);
// Set up some pressure gauge simulators at different starting points and speeds
AddPressureGauge("Pressure Gague 1", 30, 10);
AddPressureGauge("Pressure Gague 2", 50, 20);
AddPressureGauge("Pressure Gague 3", 70, 30);
// Set up the polling timer to read the gauges periodically
PollingTimer.Interval = TakeReadingsEvery.TotalMilliseconds;
PollingTimer.Elapsed += PollingTimerElapsed;
PollingTimer.Start();
while (DoMenu())
{
}
PollingTimer.Stop();
PollingTimer.Dispose();
foreach (var sensor in Sensors.Values)
sensor.Dispose();
documentStore.DocumentDatabase.StopBackgroundWorkers();
documentStore.Dispose();
}