本文整理汇总了C#中System.ByteBuffer.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.GetBytes方法的具体用法?C# ByteBuffer.GetBytes怎么用?C# ByteBuffer.GetBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.GetBytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decode
public static string Decode(ByteBuffer buffer, FormatCode formatCode)
{
if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null)
{
return null;
}
int count = 0;
Encoding encoding = null;
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.GetInvalidFormatCodeException(formatCode, buffer.Offset);
}
ArraySegment<byte> bytes = buffer.GetBytes(count);
return encoding.GetString(bytes.Array, bytes.Offset, count);
}
示例2: Decode
public static AmqpSymbol Decode(ByteBuffer buffer, FormatCode formatCode)
{
if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null)
{
return new AmqpSymbol();
}
int count = 0;
AmqpEncoding.ReadCount(buffer, formatCode, FormatCode.Symbol8, FormatCode.Symbol32, out count);
ArraySegment<byte> bytes = buffer.GetBytes(count);
return Encoding.ASCII.GetString(bytes.Array, bytes.Offset, count);
}