本文整理汇总了C#中Microsoft.Cci.BlobBuilder.WriteContentTo方法的典型用法代码示例。如果您正苦于以下问题:C# BlobBuilder.WriteContentTo方法的具体用法?C# BlobBuilder.WriteContentTo怎么用?C# BlobBuilder.WriteContentTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Cci.BlobBuilder
的用法示例。
在下文中一共展示了BlobBuilder.WriteContentTo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write_Errors
public unsafe void Write_Errors()
{
var builder = new BlobBuilder(16);
Assert.Throws<ArgumentNullException>(() => builder.WriteUTF16((char[])null));
Assert.Throws<ArgumentNullException>(() => builder.WriteUTF16((string)null));
Assert.Throws<ArgumentNullException>(() => builder.WriteUTF8(null, allowUnpairedSurrogates: true));
Assert.Throws<ArgumentNullException>(() => builder.WriteUTF8(null, allowUnpairedSurrogates: true));
Assert.Throws<ArgumentNullException>(() => builder.TryWriteBytes((Stream)null, 0));
Assert.Throws<ArgumentNullException>(() => builder.WriteBytes(null));
Assert.Throws<ArgumentNullException>(() => builder.WriteBytes(null, 0, 0));
Assert.Throws<ArgumentNullException>(() => builder.WriteBytes((byte*)null, 0));
Assert.Throws<ArgumentNullException>(() => builder.WriteBytes(default(ImmutableArray<byte>)));
Assert.Throws<ArgumentNullException>(() => builder.WriteBytes(default(ImmutableArray<byte>), 0, 0));
var bw = default(BlobWriter);
Assert.Throws<ArgumentNullException>(() => builder.WriteContentTo(ref bw));
Assert.Throws<ArgumentNullException>(() => builder.WriteContentTo((Stream)null));
Assert.Throws<ArgumentNullException>(() => builder.WriteContentTo((BlobBuilder)null));
Assert.Throws<ArgumentOutOfRangeException>(() => builder.TryWriteBytes(new MemoryStream(), -1));
Assert.Throws<ArgumentOutOfRangeException>(() => builder.WriteBytes(0, -1));
Assert.Throws<ArgumentOutOfRangeException>(() => builder.WriteBytes(new byte[] { }, 1, 0));
Assert.Throws<ArgumentOutOfRangeException>(() => builder.WriteBytes(new byte[] { }, 0, 1));
Assert.Throws<ArgumentOutOfRangeException>(() => builder.WriteBytes(new byte[] { }, 0, -1));
Assert.Throws<ArgumentOutOfRangeException>(() => builder.WriteBytes(ImmutableArray<byte>.Empty, 1, 0));
Assert.Throws<ArgumentOutOfRangeException>(() => builder.WriteBytes(ImmutableArray<byte>.Empty, 0, 1));
Assert.Throws<ArgumentOutOfRangeException>(() => builder.WriteBytes(ImmutableArray<byte>.Empty, 1, -1));
}
示例2: WriteContentToBlobBuilder
public void WriteContentToBlobBuilder()
{
var builder1 = new BlobBuilder(16);
for (int i = 0; i < 20; i++)
{
builder1.WriteByte((byte)i);
}
var builder2 = new BlobBuilder(256);
builder1.WriteContentTo(builder2);
AssertEx.Equal(new byte[]
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13
}, builder2.ToArray());
builder1.WriteByte(0xff);
builder1.WriteContentTo(builder2);
AssertEx.Equal(new byte[]
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13,
0xff,
}, builder2.ToArray());
}
示例3: WriteContentToStream
public void WriteContentToStream()
{
var builder = new BlobBuilder(16);
for (int i = 0; i < 20; i++)
{
builder.WriteByte((byte)i);
}
var stream = new MemoryStream();
builder.WriteContentTo(stream);
AssertEx.Equal(new byte[]
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13
}, stream.ToArray());
builder.WriteByte(0xff);
builder.WriteContentTo(stream);
AssertEx.Equal(new byte[]
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13,
0xff,
}, stream.ToArray());
}
示例4: WriteContentToStream_Errors
public void WriteContentToStream_Errors()
{
var builder = new BlobBuilder(16);
builder.WriteByte(1);
Assert.Throws<ArgumentNullException>(() => builder.WriteContentTo((Stream)null));
Assert.Throws<NotSupportedException>(() => builder.WriteContentTo(new MemoryStream(new byte[] { 1 }, writable: false)));
}
示例5: WriteBytes
/// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
public void WriteBytes(BlobBuilder source)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}
source.WriteContentTo(ref this);
}