本文整理汇总了C#中ByteBuffer.Complete方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.Complete方法的具体用法?C# ByteBuffer.Complete怎么用?C# ByteBuffer.Complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.Complete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decode
public static string Decode(ByteBuffer buffer, FormatCode formatCode)
{
if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null)
{
return null;
}
int count;
Encoding encoding;
if (formatCode == FormatCode.String8Utf8)
{
count = (int)AmqpBitConverter.ReadUByte(buffer);
encoding = Encoding.UTF8;
}
else if (formatCode == FormatCode.String32Utf8)
{
count = (int)AmqpBitConverter.ReadUInt(buffer);
encoding = Encoding.UTF8;
}
else
{
throw AmqpEncoding.GetEncodingException(AmqpResources.GetString(AmqpResources.AmqpInvalidFormatCode, formatCode, buffer.Offset));
}
string value = encoding.GetString(buffer.Buffer, buffer.Offset, count);
buffer.Complete(count);
return value;
}
示例2: Decode
public static AmqpSymbol Decode(ByteBuffer buffer, FormatCode formatCode)
{
if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null)
{
return new AmqpSymbol();
}
int count;
AmqpEncoding.ReadCount(buffer, formatCode, FormatCode.Symbol8, FormatCode.Symbol32, out count);
string value = Platform.System.Text.Encoding.ASCII.GetString(buffer.Buffer, buffer.Offset, count);
buffer.Complete(count);
return new AmqpSymbol(value);
}
示例3: DecodeValue
public override void DecodeValue(ByteBuffer buffer)
{
FormatCode formatCode = AmqpEncoding.ReadFormatCode(buffer);
if (formatCode == FormatCode.List0)
{
return;
}
int size = 0;
int count = 0;
AmqpEncoding.ReadSizeAndCount(buffer, formatCode, FormatCode.List8, FormatCode.List32, out size, out count);
int offset = buffer.Offset;
this.DecodeValue(buffer, size, count);
int extraCount = count - this.FieldCount;
if (extraCount > 0)
{
// we just ignore the rest of bytes. ideally we should decode the remaining objects
// to validate the buffer contains valid AMQP objects.
int bytesRemaining = size - (buffer.Offset - offset) - (formatCode == FormatCode.List8 ? FixedWidth.UByte : FixedWidth.UInt);
buffer.Complete(bytesRemaining);
}
}
示例4: DecodeValue
internal override void DecodeValue(ByteBuffer buffer)
{
// initialize the value buffer only
int offset = buffer.Offset;
byte formatCode = Encoder.ReadFormatCode(buffer);
while (formatCode == FormatCode.Described)
{
Encoder.ReadObject(buffer);
formatCode = Encoder.ReadFormatCode(buffer);
}
int count = this.GetCount(formatCode, buffer);
buffer.Validate(false, count);
buffer.Complete(count);
int size = buffer.Offset - offset;
this.valueBuffer = new ByteBuffer(buffer.Buffer, offset, size, size);
}