本文整理汇总了C#中Apache.Qpid.Buffer.ByteBuffer.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.GetBytes方法的具体用法?C# ByteBuffer.GetBytes怎么用?C# ByteBuffer.GetBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Apache.Qpid.Buffer.ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.GetBytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadShortString
/// <summary>
/// Read a short string from the buffer
/// </summary>
/// <param name="buffer">The buffer to read from.</param>
/// <returns>a string</returns>
/// <exception cref="AMQFrameDecodingException">if the buffer does not contain a decodable short string</exception>
public static string ReadShortString(ByteBuffer buffer)
{
byte length = buffer.GetByte();
if ( length == 0 )
{
return null;
} else
{
byte[] data = new byte[length];
buffer.GetBytes(data);
lock ( DEFAULT_ENCODER )
{
return DEFAULT_ENCODER.GetString(data);
}
}
}
示例2: ReadLongString
public static string ReadLongString(ByteBuffer buffer, Encoding encoding)
{
uint length = buffer.GetUInt32();
if ( length == 0 )
{
return null;
} else
{
byte[] data = new byte[length];
buffer.GetBytes(data);
lock ( encoding )
{
return encoding.GetString(data);
}
}
}
示例3: ReadLongstr
public static byte[] ReadLongstr(ByteBuffer buffer)
{
uint length = buffer.GetUInt32();
if ( length == 0 )
{
return null;
} else
{
byte[] result = new byte[length];
buffer.GetBytes(result);
return result;
}
}
示例4: Decode
/// <summary>
/// Decodes the specified session.
/// </summary>
/// <param name="inbuf">The inbuf.</param>
/// <param name="output">The protocol output.</param>
/// <returns></returns>
public MessageDecoderResult Decode(ByteBuffer inbuf, IProtocolDecoderOutput output)
{
byte[] header = new byte[4];
inbuf.GetBytes(header);
ProtocolInitiation pi = new ProtocolInitiation();
pi.Header = new char[]{'A','M','Q','P'};
pi.ProtocolClass = inbuf.GetByte();
pi.ProtocolInstance = inbuf.GetByte();
pi.ProtocolMajor = inbuf.GetByte();
pi.ProtocolMinor = inbuf.GetByte();
output.Write(pi);
return MessageDecoderResult.OK;
}