当前位置: 首页>>代码示例>>C#>>正文


C# ColumnStream.Read方法代码示例

本文整理汇总了C#中Microsoft.Isam.Esent.Interop.ColumnStream.Read方法的典型用法代码示例。如果您正苦于以下问题:C# ColumnStream.Read方法的具体用法?C# ColumnStream.Read怎么用?C# ColumnStream.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Isam.Esent.Interop.ColumnStream的用法示例。


在下文中一共展示了ColumnStream.Read方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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);
            }
        }
开发者ID:ayende,项目名称:managed-esent,代码行数:32,代码来源:ColumnStreamTests.cs

示例2: 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]);
                }
            }
        }
开发者ID:ayende,项目名称:managed-esent,代码行数:28,代码来源:ColumnStreamTests.cs

示例3: 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);
            }
        }
开发者ID:ayende,项目名称:managed-esent,代码行数:33,代码来源:ColumnStreamTests.cs

示例4: 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]);
            }
        }
开发者ID:ayende,项目名称:managed-esent,代码行数:25,代码来源:ColumnStreamTests.cs

示例5: 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);
            }
        }
开发者ID:ayende,项目名称:managed-esent,代码行数:30,代码来源:ColumnStreamTests.cs

示例6: 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);
            }
        }
开发者ID:ayende,项目名称:managed-esent,代码行数:29,代码来源:ColumnStreamTests.cs

示例7: ReadThrowsExceptionWhenNumberOfBytesIsTooLarge

 public void ReadThrowsExceptionWhenNumberOfBytesIsTooLarge()
 {
     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.Read(buffer, 1, buffer.Length);
     }
 }
开发者ID:jtmueller,项目名称:ravendb,代码行数:10,代码来源:ColumnStreamTests.cs

示例8: ReadThrowsExceptionWhenBufferOffsetIsNegative

 public void ReadThrowsExceptionWhenBufferOffsetIsNegative()
 {
     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.Read(buffer, -1, 1);
     }
 }
开发者ID:jtmueller,项目名称:ravendb,代码行数:10,代码来源:ColumnStreamTests.cs

示例9: ReadThrowsExceptionWhenBufferIsNull

 public void ReadThrowsExceptionWhenBufferIsNull()
 {
     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.Read(null, 0, 0);
     }
 }
开发者ID:jtmueller,项目名称:ravendb,代码行数:9,代码来源:ColumnStreamTests.cs


注:本文中的Microsoft.Isam.Esent.Interop.ColumnStream.Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。