本文整理汇总了C#中Microsoft.Isam.Esent.Interop.ColumnStream.Write方法的典型用法代码示例。如果您正苦于以下问题:C# ColumnStream.Write方法的具体用法?C# ColumnStream.Write怎么用?C# ColumnStream.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Isam.Esent.Interop.ColumnStream
的用法示例。
在下文中一共展示了ColumnStream.Write方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteThrowsExceptionWhenBufferOffsetIsNegative
public void WriteThrowsExceptionWhenBufferOffsetIsNegative()
{
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))
{
var buffer = new byte[10];
stream.Write(buffer, -1, 1);
}
}
示例2: WriteThrowsExceptionWhenNumberOfBytesIsTooLarge
public void WriteThrowsExceptionWhenNumberOfBytesIsTooLarge()
{
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))
{
var buffer = new byte[10];
stream.Write(buffer, 1, buffer.Length);
}
}
示例3: WriteAtNonZeroOffset
public void WriteAtNonZeroOffset()
{
var bookmark = new byte[SystemParameters.BookmarkMost];
int bookmarkSize;
var data = Any.BytesOfLength(1024);
int offset = data.Length / 2;
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, offset, data.Length - offset);
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 - offset];
stream.Read(retrieved, 0, retrieved.Length);
for (int i = 0; i < retrieved.Length; ++i)
{
Assert.AreEqual(retrieved[i], data[i + offset]);
}
}
}
示例4: WriteThrowsExceptionWhenBufferIsNull
public void WriteThrowsExceptionWhenBufferIsNull()
{
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(null, 0, 0);
}
}
示例5: SetColumnStreamToZeroLength
public void SetColumnStreamToZeroLength()
{
var bookmark = new byte[SystemParameters.BookmarkMost];
int bookmarkSize;
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))
{
byte[] data = Any.Bytes;
stream.Write(data, 0, data.Length);
stream.SetLength(0);
Assert.AreEqual(0, stream.Length);
update.Save(bookmark, bookmark.Length, out bookmarkSize);
transaction.Commit(CommitTransactionGrbit.LazyFlush);
}
Api.JetGotoBookmark(this.sesid, this.tableid, bookmark, bookmarkSize);
CollectionAssert.AreEqual(new byte[0], Api.RetrieveColumn(this.sesid, this.tableid, this.columnidLongText));
}
示例6: ShrinkColumnStream
public void ShrinkColumnStream()
{
var bookmark = new byte[SystemParameters.BookmarkMost];
int bookmarkSize;
const int Length = 1345;
var data = Any.BytesOfLength(Length);
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.Write(data, 0, data.Length);
Assert.AreEqual(Length * 2, stream.Length);
stream.SetLength(Length);
Assert.AreEqual(Length, stream.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(Length, stream.Length);
var buffer = new byte[Length];
stream.Read(buffer, 0, buffer.Length);
CollectionAssert.AreEqual(data, buffer);
}
}
示例7: 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]);
}
}
示例8: SetColumnStreamPosition
public void SetColumnStreamPosition()
{
var bookmark = new byte[SystemParameters.BookmarkMost];
int bookmarkSize;
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(Any.BytesOfLength(1024), 0, 1024);
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))
{
stream.Position = 10;
Assert.AreEqual(10, stream.Position);
}
}
示例9: 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);
}
}
示例10: GrowColumnStreamByWritingPastEnd
public void GrowColumnStreamByWritingPastEnd()
{
var bookmark = new byte[SystemParameters.BookmarkMost];
int bookmarkSize;
const int Length = 1345;
const int Position = 1500;
var data = Any.BytesOfLength(Length);
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.Position = Position;
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))
{
Assert.AreEqual(Length + Position, stream.Length);
var expected = new byte[Length + Position];
var actual = new byte[Length + Position];
Array.Copy(data, 0, expected, Position, Length);
Assert.AreEqual(Length + Position, stream.Read(actual, 0, actual.Length));
CollectionAssert.AreEqual(expected, actual);
}
}
示例11: 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);
}
}
示例12: 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
}
}
}
示例13: 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
}
}
}