本文整理汇总了C#中Microsoft.Isam.Esent.Interop.ColumnStream.Seek方法的典型用法代码示例。如果您正苦于以下问题:C# ColumnStream.Seek方法的具体用法?C# ColumnStream.Seek怎么用?C# ColumnStream.Seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Isam.Esent.Interop.ColumnStream
的用法示例。
在下文中一共展示了ColumnStream.Seek方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SeekingPastEndOfColumnStreamDoesNotGrowStream
public void SeekingPastEndOfColumnStreamDoesNotGrowStream()
{
const int Offset = 1200;
Api.JetBeginTransaction(this.sesid);
Api.JetPrepareUpdate(this.sesid, this.tableid, JET_prep.Insert);
using (var stream = new ColumnStream(this.sesid, this.tableid, this.columnidLongText))
{
stream.Seek(Offset, SeekOrigin.Begin);
}
this.UpdateAndGotoBookmark();
Api.JetCommitTransaction(this.sesid, CommitTransactionGrbit.LazyFlush);
using (var stream = new ColumnStream(this.sesid, this.tableid, this.columnidLongText))
{
Assert.AreEqual(0, stream.Length);
}
}
示例2: OverwriteColumnStream
public void OverwriteColumnStream()
{
var bookmark = new byte[SystemParameters.BookmarkMost];
int bookmarkSize;
var data = Any.BytesOfLength(1024);
var newData = Any.BytesOfLength(128);
const int Offset = 10;
using (var transaction = new Transaction(this.sesid))
using (var update = new Update(this.sesid, this.tableid, JET_prep.Insert))
using (var stream = new ColumnStream(this.sesid, this.tableid, this.columnidLongText))
{
stream.Write(data, 0, data.Length);
stream.Position = 0;
stream.Seek(Offset, SeekOrigin.Current);
stream.Write(newData, 0, newData.Length);
update.Save(bookmark, bookmark.Length, out bookmarkSize);
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
Api.JetGotoBookmark(this.sesid, this.tableid, bookmark, bookmarkSize);
using (var stream = new ColumnStream(this.sesid, this.tableid, this.columnidLongText))
{
Assert.AreEqual(data.Length, stream.Length);
var retrieved = new byte[data.Length];
var expected = new byte[data.Length];
Array.Copy(data, 0, expected, 0, data.Length);
Array.Copy(newData, 0, expected, Offset, newData.Length);
Assert.AreEqual(retrieved.Length, stream.Read(retrieved, 0, retrieved.Length));
CollectionAssert.AreEqual(expected, retrieved);
}
}
示例3: ReadReturnsNumberOfBytesRead
public void ReadReturnsNumberOfBytesRead()
{
var bookmark = new byte[SystemParameters.BookmarkMost];
int bookmarkSize;
var data = Any.BytesOfLength(1024);
using (var transaction = new Transaction(this.sesid))
using (var update = new Update(this.sesid, this.tableid, JET_prep.Insert))
using (var stream = new ColumnStream(this.sesid, this.tableid, this.columnidLongText))
{
stream.Write(data, 0, data.Length);
update.Save(bookmark, bookmark.Length, out bookmarkSize);
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
Api.JetGotoBookmark(this.sesid, this.tableid, bookmark, bookmarkSize);
using (var stream = new ColumnStream(this.sesid, this.tableid, this.columnidLongText))
{
var retrieved = new byte[data.Length];
stream.Seek(-1, SeekOrigin.End);
Assert.AreEqual(1, stream.Read(retrieved, 0, retrieved.Length));
Assert.AreEqual(data[data.Length - 1], retrieved[0]);
}
}
示例4: ExtendingColumnStream
public void ExtendingColumnStream()
{
var bookmark = new byte[SystemParameters.BookmarkMost];
int bookmarkSize;
var data = Any.BytesOfLength(4096);
using (var transaction = new Transaction(this.sesid))
using (var update = new Update(this.sesid, this.tableid, JET_prep.Insert))
using (var stream = new ColumnStream(this.sesid, this.tableid, this.columnidLongText))
{
// Write some of the data, rewind a bit and then overwrite the
// last few bytes and append some more data
stream.Write(data, 0, data.Length - 10);
stream.Seek(-10, SeekOrigin.End);
stream.Write(data, data.Length - 20, 20);
update.Save(bookmark, bookmark.Length, out bookmarkSize);
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
Api.JetGotoBookmark(this.sesid, this.tableid, bookmark, bookmarkSize);
using (var stream = new ColumnStream(this.sesid, this.tableid, this.columnidLongText))
{
Assert.AreEqual(data.Length, stream.Length);
var retrieved = new byte[data.Length];
Assert.AreEqual(retrieved.Length, stream.Read(retrieved, 0, retrieved.Length));
CollectionAssert.AreEqual(data, retrieved);
}
}
示例5: ColumnStreamThrowsExceptionWhenSeekOffsetIsTooLarge
public void ColumnStreamThrowsExceptionWhenSeekOffsetIsTooLarge()
{
using (var t = new Transaction(this.sesid))
using (var u = new Update(this.sesid, this.tableid, JET_prep.Insert))
using (var stream = new ColumnStream(this.sesid, this.tableid, this.columnidLongText))
{
stream.Seek(0x800000000, SeekOrigin.Begin);
}
}
示例6: VerifySeekFromEndThrowsExceptionOnOverflow
public void VerifySeekFromEndThrowsExceptionOnOverflow()
{
using (var t = new Transaction(this.sesid))
using (var u = new Update(this.sesid, this.tableid, JET_prep.Insert))
using (var stream = new ColumnStream(this.sesid, this.tableid, this.columnidLongText))
{
stream.Write(new byte[10], 0, 10);
try
{
stream.Seek(Int64.MaxValue, SeekOrigin.End);
Assert.Fail("Expected OverflowException");
}
catch (OverflowException)
{
// expected
}
}
}
示例7: ColumnStreamThrowsExceptionWhenSeekOriginIsInvalid
public void ColumnStreamThrowsExceptionWhenSeekOriginIsInvalid()
{
using (var t = new Transaction(this.sesid))
using (var u = new Update(this.sesid, this.tableid, JET_prep.Insert))
using (var stream = new ColumnStream(this.sesid, this.tableid, this.columnidLongText))
{
stream.Seek(0x800000000, (SeekOrigin)0x1234);
}
}
示例8: WritePastMaxSizeThrowsException
public void WritePastMaxSizeThrowsException()
{
var data = new byte[256];
using (var transaction = new Transaction(this.sesid))
using (var update = new Update(this.sesid, this.tableid, JET_prep.Insert))
using (var stream = new ColumnStream(this.sesid, this.tableid, this.columnidLongText))
{
stream.Seek(Int32.MaxValue - 10, SeekOrigin.Begin);
try
{
stream.Write(data, 0, data.Length);
Assert.Fail("Expected OverflowException");
}
catch (OverflowException)
{
// expected
}
}
}