本文整理汇总了C#中Microsoft.Isam.Esent.Interop.Instance.Term方法的典型用法代码示例。如果您正苦于以下问题:C# Instance.Term方法的具体用法?C# Instance.Term怎么用?C# Instance.Term使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Isam.Esent.Interop.Instance
的用法示例。
在下文中一共展示了Instance.Term方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateInstanceInitTerm
public void CreateInstanceInitTerm()
{
string dir = SetupHelper.CreateRandomDirectory();
using (var instance = new Instance("theinstance"))
{
instance.Parameters.LogFileDirectory = dir;
instance.Parameters.SystemDirectory = dir;
instance.Parameters.TempDirectory = dir;
instance.Parameters.NoInformationEvent = true;
instance.Init();
instance.Term();
Directory.Delete(dir, true); // only works if the instance is terminated
}
}
示例2: CreateInstanceInitTerm
public void CreateInstanceInitTerm()
{
string dir = SetupHelper.CreateRandomDirectory();
using (var instance = new Instance("initterm"))
{
instance.Parameters.LogFileDirectory = dir;
instance.Parameters.SystemDirectory = dir;
instance.Parameters.TempDirectory = dir;
instance.Parameters.LogFileSize = 256; // 256Kb
instance.Parameters.NoInformationEvent = true;
instance.Init();
instance.Term();
Cleanup.DeleteDirectoryWithRetry(dir); // only works if the instance is terminated
}
}
示例3: ExecuteInDatabase
protected void ExecuteInDatabase(Action<Session, JET_DBID> action)
{
var instance = new Instance(databasePath);
try
{
instance.Parameters.CircularLog = true;
instance.Parameters.CreatePathIfNotExist = true;
instance.Parameters.TempDirectory = Path.Combine(Path.GetDirectoryName(databasePath), "temp");
instance.Parameters.SystemDirectory = Path.Combine(Path.GetDirectoryName(databasePath), "system");
instance.Parameters.LogFileDirectory = Path.Combine(Path.GetDirectoryName(databasePath), "logs");
instance.Init();
using (var session = new Session(instance))
{
Api.JetAttachDatabase(session, databasePath, AttachDatabaseGrbit.None);
try
{
using (var tx = new Transaction(session))
{
JET_DBID dbid;
Api.JetOpenDatabase(session, databasePath, "", out dbid, OpenDatabaseGrbit.None);
try
{
action(session, dbid);
tx.Commit(CommitTransactionGrbit.None);
}
finally
{
Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None);
}
}
}
finally
{
Api.JetDetachDatabase(session, databasePath);
}
}
}
finally
{
instance.Term();
}
}
示例4: TermThrowsExceptionWhenInstanceIsDisposed
public void TermThrowsExceptionWhenInstanceIsDisposed()
{
var instance = new Instance("theinstance");
instance.Dispose();
instance.Term();
}
示例5: JetInstanceThrowsExceptionWhenInstanceIsClosed
public void JetInstanceThrowsExceptionWhenInstanceIsClosed()
{
var instance = new Instance("theinstance");
instance.Parameters.NoInformationEvent = true;
instance.Parameters.Recovery = false;
instance.Parameters.MaxTemporaryTables = 0;
instance.Init();
instance.Term();
JET_INSTANCE x = instance.JetInstance;
}
示例6: InstanceInitTermThread
/// <summary>
/// Init and term an instance. This is used to make sure the instance
/// is always cleaned up when the thread is terminated. If the cleanup
/// is missed the next instance create will fail.
/// </summary>
/// <param name="instanceName">
/// The name of the instance to create.
/// </param>
private static void InstanceInitTermThread(string instanceName)
{
try
{
while (true)
{
using (var instance = new Instance(instanceName))
{
SetupHelper.SetLightweightConfiguration(instance);
instance.Init();
instance.Term();
}
}
}
catch (ThreadAbortException)
{
// Actually letting the thread abort will fail the test, exit
// gracefully instead.
Thread.ResetAbort();
}
catch (EsentErrorException ex)
{
Console.WriteLine("Got exception {0}", ex);
Assert.Fail("Got exception {0}", ex);
}
}
示例7: JetInstanceThrowsExceptionWhenInstanceIsClosed
public void JetInstanceThrowsExceptionWhenInstanceIsClosed()
{
var instance = new Instance("closed");
SetupHelper.SetLightweightConfiguration(instance);
instance.Init();
instance.Term();
JET_INSTANCE x = instance.JetInstance;
}
示例8: CreateNewInstanceAndConnection
/// <summary>
/// Create a new instance and a connection on that instance.
/// A new InstanceInfo is added to the instance dictionary.
/// </summary>
/// <param name="database">The database to connect to.</param>
/// <param name="mode">The mode to connect to the database in.</param>
/// <returns>A new Connection to the database.</returns>
private Connection CreateNewInstanceAndConnection(string database, DatabaseOpenMode mode)
{
var instanceName = this.GetNewInstanceName();
var instance = new Instance(instanceName);
this.Tracer.TraceInfo("created instance '{0}'", instanceName);
try
{
SetParametersAndInitializeInstance(database, instance);
this.instances[database] = new InstanceInfo(instance, database);
return this.CreateNewConnection(database, mode);
}
catch (Exception)
{
// Creating the new instance failed. Terminate ESE and remove the
// instance information.
instance.Term();
this.instances.Remove(database);
throw;
}
}