本文整理汇总了C#中Microsoft.Cci.BlobBuilder.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# BlobBuilder.Clear方法的具体用法?C# BlobBuilder.Clear怎么用?C# BlobBuilder.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Cci.BlobBuilder
的用法示例。
在下文中一共展示了BlobBuilder.Clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CountClear
public void CountClear()
{
var builder = new BlobBuilder();
Assert.Equal(0, builder.Count);
builder.WriteByte(1);
Assert.Equal(1, builder.Count);
builder.WriteInt32(4);
Assert.Equal(5, builder.Count);
builder.Clear();
Assert.Equal(0, builder.Count);
builder.WriteInt64(1);
Assert.Equal(8, builder.Count);
AssertEx.Equal(new byte[] { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, builder.ToArray());
}
示例2: GetBlobs
public void GetBlobs()
{
var builder = new BlobBuilder(16);
builder.WriteBytes(1, 100);
var blobs = builder.GetBlobs().ToArray();
Assert.Equal(2, blobs.Length);
Assert.Equal(16, blobs[0].Length);
Assert.Equal(100 - 16, blobs[1].Length);
builder.WriteByte(1);
blobs = builder.GetBlobs().ToArray();
Assert.Equal(3, blobs.Length);
Assert.Equal(16, blobs[0].Length);
Assert.Equal(16, blobs[0].GetUnderlyingBuffer().Array.Length);
Assert.Equal(100 - 16, blobs[1].Length);
Assert.Equal(100 - 16, blobs[1].GetUnderlyingBuffer().Array.Length);
Assert.Equal(1, blobs[2].Length);
Assert.Equal(100 - 16, blobs[2].GetUnderlyingBuffer().Array.Length);
builder.Clear();
blobs = builder.GetBlobs().ToArray();
Assert.Equal(1, blobs.Length);
Assert.Equal(0, blobs[0].Length);
// Clear uses the first buffer:
Assert.Equal(16, blobs[0].GetUnderlyingBuffer().Array.Length);
}