本文整理汇总了C#中Microsoft.Isam.Esent.Interop.Session.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Session.Dispose方法的具体用法?C# Session.Dispose怎么用?C# Session.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Isam.Esent.Interop.Session
的用法示例。
在下文中一共展示了Session.Dispose方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DocumentStorageActions
public DocumentStorageActions(
JET_INSTANCE instance,
string database,
TableColumnsCache tableColumnsCache,
OrderedPartCollection<AbstractDocumentCodec> documentCodecs,
IUuidGenerator uuidGenerator,
IDocumentCacher cacher,
EsentTransactionContext transactionContext,
TransactionalStorage transactionalStorage)
{
this.tableColumnsCache = tableColumnsCache;
this.documentCodecs = documentCodecs;
this.uuidGenerator = uuidGenerator;
this.cacher = cacher;
this.transactionalStorage = transactionalStorage;
this.transactionContext = transactionContext;
try
{
if (transactionContext == null)
{
session = new Session(instance);
transaction = new Transaction(session);
sessionAndTransactionDisposer = () =>
{
if(transaction != null)
transaction.Dispose();
if(session != null)
session.Dispose();
};
}
else
{
session = transactionContext.Session;
transaction = transactionContext.Transaction;
var disposable = transactionContext.EnterSessionContext();
sessionAndTransactionDisposer = disposable.Dispose;
}
Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.None);
}
catch (Exception ex)
{
logger.WarnException("Error when trying to open a new DocumentStorageActions", ex);
try
{
Dispose();
}
catch (Exception e)
{
logger.WarnException("Error on dispose when the ctor threw an exception, resources may have leaked", e);
}
throw;
}
}
示例2: JetSesidThrowsExceptionWhenSessionIsDisposed
public void JetSesidThrowsExceptionWhenSessionIsDisposed()
{
var session = new Session(this.instance);
session.Dispose();
JET_SESID x = session.JetSesid;
}
示例3: EndThrowsExceptionWhenSessionIsDisposed
public void EndThrowsExceptionWhenSessionIsDisposed()
{
var session = new Session(this.instance);
session.Dispose();
session.End();
}
示例4: OpenCursor
private void OpenCursor(string jetDatabase, Instance jetInstance,
out Session jetSession,
out JET_DBID chainStateDbId,
out JET_TABLEID globalsTableId,
out JET_COLUMNID chainTipColumnId,
out JET_COLUMNID unspentTxCountColumnId,
out JET_COLUMNID unspentOutputCountColumnId,
out JET_COLUMNID totalTxCountColumnId,
out JET_COLUMNID totalInputCountColumnId,
out JET_COLUMNID totalOutputCountColumnId,
out JET_TABLEID flushTableId,
out JET_COLUMNID flushColumnId,
out JET_TABLEID headersTableId,
out JET_COLUMNID headerBlockHashColumnId,
out JET_COLUMNID headerBytesColumnId,
out JET_TABLEID unspentTxTableId,
out JET_COLUMNID txHashColumnId,
out JET_COLUMNID blockIndexColumnId,
out JET_COLUMNID txIndexColumnId,
out JET_COLUMNID txVersionColumnId,
out JET_COLUMNID isCoinbaseColumnId,
out JET_COLUMNID outputStatesColumnId,
out JET_TABLEID unspentTxOutputTableId,
out JET_COLUMNID txOutputKeyColumnId,
out JET_COLUMNID txOutputBytesColumnId,
out JET_TABLEID spentTxTableId,
out JET_COLUMNID spentSpentBlockIndexColumnId,
out JET_COLUMNID spentDataColumnId,
out JET_TABLEID unmintedTxTableId,
out JET_COLUMNID unmintedBlockHashColumnId,
out JET_COLUMNID unmintedDataColumnId)
{
var success = false;
jetSession = new Session(jetInstance);
try
{
Api.JetOpenDatabase(jetSession, jetDatabase, "", out chainStateDbId, OpenDatabaseGrbit.None);
Api.JetOpenTable(jetSession, chainStateDbId, "Globals", null, 0, OpenTableGrbit.None, out globalsTableId);
chainTipColumnId = Api.GetTableColumnid(jetSession, globalsTableId, "ChainTip");
unspentTxCountColumnId = Api.GetTableColumnid(jetSession, globalsTableId, "UnspentTxCount");
unspentOutputCountColumnId = Api.GetTableColumnid(jetSession, globalsTableId, "UnspentOutputCount");
totalTxCountColumnId = Api.GetTableColumnid(jetSession, globalsTableId, "TotalTxCount");
totalInputCountColumnId = Api.GetTableColumnid(jetSession, globalsTableId, "TotalInputCount");
totalOutputCountColumnId = Api.GetTableColumnid(jetSession, globalsTableId, "TotalOutputCount");
if (!Api.TryMoveFirst(jetSession, globalsTableId))
throw new InvalidOperationException();
Api.JetOpenTable(jetSession, chainStateDbId, "Flush", null, 0, OpenTableGrbit.None, out flushTableId);
flushColumnId = Api.GetTableColumnid(jetSession, flushTableId, "Flush");
if (!Api.TryMoveFirst(jetSession, flushTableId))
throw new InvalidOperationException();
Api.JetOpenTable(jetSession, chainStateDbId, "Headers", null, 0, OpenTableGrbit.None, out headersTableId);
headerBlockHashColumnId = Api.GetTableColumnid(jetSession, headersTableId, "BlockHash");
headerBytesColumnId = Api.GetTableColumnid(jetSession, headersTableId, "HeaderBytes");
Api.JetOpenTable(jetSession, chainStateDbId, "UnspentTx", null, 0, OpenTableGrbit.None, out unspentTxTableId);
txHashColumnId = Api.GetTableColumnid(jetSession, unspentTxTableId, "TxHash");
blockIndexColumnId = Api.GetTableColumnid(jetSession, unspentTxTableId, "BlockIndex");
txIndexColumnId = Api.GetTableColumnid(jetSession, unspentTxTableId, "TxIndex");
txVersionColumnId = Api.GetTableColumnid(jetSession, unspentTxTableId, "TxVersion");
isCoinbaseColumnId = Api.GetTableColumnid(jetSession, unspentTxTableId, "IsCoinbase");
outputStatesColumnId = Api.GetTableColumnid(jetSession, unspentTxTableId, "OutputStates");
Api.JetOpenTable(jetSession, chainStateDbId, "UnspentTxOutput", null, 0, OpenTableGrbit.None, out unspentTxOutputTableId);
txOutputKeyColumnId = Api.GetTableColumnid(jetSession, unspentTxOutputTableId, "TxOutputKey");
txOutputBytesColumnId = Api.GetTableColumnid(jetSession, unspentTxOutputTableId, "TxOutputBytes");
Api.JetOpenTable(jetSession, chainStateDbId, "SpentTx", null, 0, OpenTableGrbit.None, out spentTxTableId);
spentSpentBlockIndexColumnId = Api.GetTableColumnid(jetSession, spentTxTableId, "SpentBlockIndex");
spentDataColumnId = Api.GetTableColumnid(jetSession, spentTxTableId, "SpentData");
Api.JetOpenTable(jetSession, chainStateDbId, "UnmintedTx", null, 0, OpenTableGrbit.None, out unmintedTxTableId);
unmintedBlockHashColumnId = Api.GetTableColumnid(jetSession, unmintedTxTableId, "BlockHash");
unmintedDataColumnId = Api.GetTableColumnid(jetSession, unmintedTxTableId, "UnmintedData");
success = true;
}
finally
{
if (!success)
jetSession.Dispose();
}
}
示例5: OpenCursor
private void OpenCursor(string jetDatabase, Instance jetInstance, bool readOnly,
out Session jetSession,
out JET_DBID blockDbId,
out JET_TABLEID globalsTableId,
out JET_COLUMNID flushColumnId,
out JET_TABLEID blockHeadersTableId,
out JET_COLUMNID blockHeaderHashColumnId,
out JET_COLUMNID blockHeaderPreviousHashColumnId,
out JET_COLUMNID blockHeaderHeightColumnId,
out JET_COLUMNID blockHeaderTotalWorkColumnId,
out JET_COLUMNID blockHeaderValidColumnId,
out JET_COLUMNID blockHeaderBytesColumnId)
{
jetSession = new Session(jetInstance);
var success = false;
try
{
Api.JetOpenDatabase(jetSession, jetDatabase, "", out blockDbId, readOnly ? OpenDatabaseGrbit.ReadOnly : OpenDatabaseGrbit.None);
Api.JetOpenTable(jetSession, blockDbId, "Globals", null, 0, readOnly ? OpenTableGrbit.ReadOnly : OpenTableGrbit.None, out globalsTableId);
flushColumnId = Api.GetTableColumnid(jetSession, globalsTableId, "Flush");
if (!Api.TryMoveFirst(jetSession, globalsTableId))
throw new InvalidOperationException();
Api.JetOpenTable(jetSession, blockDbId, "BlockHeaders", null, 0, readOnly ? OpenTableGrbit.ReadOnly : OpenTableGrbit.None, out blockHeadersTableId);
blockHeaderHashColumnId = Api.GetTableColumnid(jetSession, blockHeadersTableId, "BlockHash");
blockHeaderPreviousHashColumnId = Api.GetTableColumnid(jetSession, blockHeadersTableId, "PreviousBlockHash");
blockHeaderHeightColumnId = Api.GetTableColumnid(jetSession, blockHeadersTableId, "Height");
blockHeaderTotalWorkColumnId = Api.GetTableColumnid(jetSession, blockHeadersTableId, "TotalWork");
blockHeaderValidColumnId = Api.GetTableColumnid(jetSession, blockHeadersTableId, "Valid");
blockHeaderBytesColumnId = Api.GetTableColumnid(jetSession, blockHeadersTableId, "BlockHeaderBytes");
success = true;
}
finally
{
if (!success)
jetSession.Dispose();
}
}
示例6: OpenCursor
private void OpenCursor(string jetDatabase, Instance jetInstance, bool readOnly,
out Session jetSession,
out JET_DBID blockDbId,
out JET_TABLEID globalsTableId,
out JET_COLUMNID blockCountColumnId,
out JET_COLUMNID flushColumnId,
out JET_TABLEID blockIndexTableId,
out JET_COLUMNID blockIndexBlockHashColumnId,
out JET_COLUMNID blockIndexBlockIndexColumnId,
out JET_TABLEID blocksTableId,
out JET_COLUMNID blockIndexColumnId,
out JET_COLUMNID txIndexColumnId,
out JET_COLUMNID blockDepthColumnId,
out JET_COLUMNID blockTxHashColumnId,
out JET_COLUMNID blockTxBytesColumnId)
{
jetSession = new Session(jetInstance);
var success = false;
try
{
Api.JetOpenDatabase(jetSession, jetDatabase, "", out blockDbId, readOnly ? OpenDatabaseGrbit.ReadOnly : OpenDatabaseGrbit.None);
Api.JetOpenTable(jetSession, blockDbId, "Globals", null, 0, readOnly ? OpenTableGrbit.ReadOnly : OpenTableGrbit.None, out globalsTableId);
blockCountColumnId = Api.GetTableColumnid(jetSession, globalsTableId, "BlockCount");
flushColumnId = Api.GetTableColumnid(jetSession, globalsTableId, "Flush");
if (!Api.TryMoveFirst(jetSession, globalsTableId))
throw new InvalidOperationException();
Api.JetOpenTable(jetSession, blockDbId, "BlockIndex", null, 0, readOnly ? OpenTableGrbit.ReadOnly : OpenTableGrbit.None, out blockIndexTableId);
blockIndexBlockHashColumnId = Api.GetTableColumnid(jetSession, blockIndexTableId, "BlockHash");
blockIndexBlockIndexColumnId = Api.GetTableColumnid(jetSession, blockIndexTableId, "BlockIndex");
Api.JetOpenTable(jetSession, blockDbId, "Blocks", null, 0, readOnly ? OpenTableGrbit.ReadOnly : OpenTableGrbit.None, out blocksTableId);
blockIndexColumnId = Api.GetTableColumnid(jetSession, blocksTableId, "BlockIndex");
txIndexColumnId = Api.GetTableColumnid(jetSession, blocksTableId, "TxIndex");
blockDepthColumnId = Api.GetTableColumnid(jetSession, blocksTableId, "Depth");
blockTxHashColumnId = Api.GetTableColumnid(jetSession, blocksTableId, "TxHash");
blockTxBytesColumnId = Api.GetTableColumnid(jetSession, blocksTableId, "TxBytes");
success = true;
}
finally
{
if (!success)
jetSession.Dispose();
}
}