本文整理汇总了C#中ByteBuffer.Append方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.Append方法的具体用法?C# ByteBuffer.Append怎么用?C# ByteBuffer.Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.Append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EscapeString
/**
* Escapes a <CODE>byte</CODE> array according to the PDF conventions.
*
* @param b the <CODE>byte</CODE> array to escape
*/
public static void EscapeString(byte[] bytes, ByteBuffer content) {
content.Append_i('(');
for (int k = 0; k < bytes.Length; ++k) {
byte c = bytes[k];
switch ((int) c) {
case '\r':
content.Append(r);
break;
case '\n':
content.Append(n);
break;
case '\t':
content.Append(t);
break;
case '\b':
content.Append(b);
break;
case '\f':
content.Append(f);
break;
case '(':
case ')':
case '\\':
content.Append_i('\\').Append_i(c);
break;
default:
content.Append_i(c);
break;
}
}
content.Append(')');
}
示例2: EncodeValue
public override void EncodeValue(ByteBuffer buffer)
{
if (this.FieldCount == 0)
{
AmqpBitConverter.WriteUByte(buffer, (byte)FormatCode.List0);
}
else
{
int valueSize = this.OnValueSize();
int encodeWidth = AmqpEncoding.GetEncodeWidthByCountAndSize(this.FieldCount, valueSize);
int sizeOffset = 0;
if (encodeWidth == FixedWidth.UByte)
{
AmqpBitConverter.WriteUByte(buffer, (byte)FormatCode.List8);
sizeOffset = buffer.Length;
buffer.Append(FixedWidth.UByte);
AmqpBitConverter.WriteUByte(buffer, (byte)this.FieldCount);
}
else
{
AmqpBitConverter.WriteUByte(buffer, (byte)FormatCode.List32);
sizeOffset = buffer.Length;
buffer.Append(FixedWidth.UInt);
AmqpBitConverter.WriteUInt(buffer, (uint)this.FieldCount);
}
this.OnEncode(buffer);
// the actual encoded value size may be different from the calculated
// valueSize. However, it can only become smaller. This allows for
// reserving space in the buffer using the longest encoding form of a
// value. For example, if the delivery id of a transfer is unknown, we
// can use uint.Max for calculating encode size, but the actual encoding
// could be small uint.
int size = buffer.Length - sizeOffset - encodeWidth;
if (encodeWidth == FixedWidth.UByte)
{
AmqpBitConverter.WriteUByte(buffer.Buffer, sizeOffset, (byte)size);
}
else
{
AmqpBitConverter.WriteUInt(buffer.Buffer, sizeOffset, (uint)size);
}
}
}
示例3: Encode
public static void Encode(ByteBuffer buffer, FrameType type, ushort channel, DescribedList command)
{
buffer.Append(FixedWidth.UInt);
AmqpBitConverter.WriteUByte(buffer, DOF);
AmqpBitConverter.WriteUByte(buffer, (byte)type);
AmqpBitConverter.WriteUShort(buffer, channel);
Codec.Encode(command, buffer);
AmqpBitConverter.WriteInt(buffer.Buffer, buffer.Offset, buffer.Length);
}