本文整理汇总了C#中IByteBuffer.WithOrder方法的典型用法代码示例。如果您正苦于以下问题:C# IByteBuffer.WithOrder方法的具体用法?C# IByteBuffer.WithOrder怎么用?C# IByteBuffer.WithOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IByteBuffer
的用法示例。
在下文中一共展示了IByteBuffer.WithOrder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUnadjustedFrameLength
/// <summary>
/// Decodes the specified region of the buffer into an unadjusted frame length. The default implementation is
/// capable of decoding the specified region into an unsigned 8/16/24/32/64 bit integer. Override this method to
/// decode the length field encoded differently.
/// Note that this method must not modify the state of the specified buffer (e.g.
/// <see cref="IByteBuffer.ReaderIndex" />,
/// <see cref="IByteBuffer.WriterIndex" />, and the content of the buffer.)
/// </summary>
/// <param name="buffer">The buffer we'll be extracting the frame length from.</param>
/// <param name="offset">The offset from the absolute <see cref="IByteBuffer.ReaderIndex" />.</param>
/// <param name="length">The length of the framelenght field. Expected: 1, 2, 3, 4, or 8.</param>
/// <param name="order">The preferred <see cref="ByteOrder" /> of <see cref="buffer" />.</param>
/// <returns>A long integer that represents the unadjusted length of the next frame.</returns>
protected long GetUnadjustedFrameLength(IByteBuffer buffer, int offset, int length, ByteOrder order)
{
buffer = buffer.WithOrder(order);
long frameLength;
switch (length)
{
case 1:
frameLength = buffer.GetByte(offset);
break;
case 2:
frameLength = buffer.GetShort(offset);
break;
case 4:
frameLength = buffer.GetInt(offset);
break;
case 8:
frameLength = buffer.GetLong(offset);
break;
default:
throw new DecoderException("unsupported lengthFieldLength: " + this.lengthFieldLength + " (expected: 1, 2, 3, 4, or 8)");
}
return frameLength;
}
示例2: AddComponent0
void AddComponent0(int cIndex, IByteBuffer buffer)
{
Contract.Requires(buffer != null);
this.CheckComponentIndex(cIndex);
int readableBytes = buffer.ReadableBytes;
// No need to consolidate - just add a component to the list.
var c = new ComponentEntry(buffer.WithOrder(ByteOrder.BigEndian).Slice());
if (cIndex == this.components.Count)
{
this.components.Add(c);
if (cIndex == 0)
{
c.EndOffset = readableBytes;
}
else
{
ComponentEntry prev = this.components[cIndex - 1];
c.Offset = prev.EndOffset;
c.EndOffset = c.Offset + readableBytes;
}
}
else
{
this.components.Insert(cIndex, c);
if (readableBytes != 0)
{
this.UpdateComponentOffsets(cIndex);
}
}
}