本文整理汇总了C#中System.ByteBuffer.EnsureSize方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.EnsureSize方法的具体用法?C# ByteBuffer.EnsureSize怎么用?C# ByteBuffer.EnsureSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.EnsureSize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteUuid
public static void WriteUuid(ByteBuffer buffer, Guid data)
{
buffer.EnsureSize(FixedWidth.Uuid);
fixed (byte* d = &buffer.Buffer[buffer.End])
{
byte* p = (byte*)&data;
d[0] = p[3];
d[1] = p[2];
d[2] = p[1];
d[3] = p[0];
d[4] = p[5];
d[5] = p[4];
d[6] = p[7];
d[7] = p[6];
*((ulong*)&d[8]) = *((ulong*)&p[8]);
}
buffer.Append(FixedWidth.Uuid);
}
示例2: WriteDouble
public static void WriteDouble(ByteBuffer buffer, double data)
{
buffer.EnsureSize(FixedWidth.Double);
fixed (byte* d = &buffer.Buffer[buffer.End])
{
byte* p = (byte*)&data;
d[0] = p[7];
d[1] = p[6];
d[2] = p[5];
d[3] = p[4];
d[4] = p[3];
d[5] = p[2];
d[6] = p[1];
d[7] = p[0];
}
buffer.Append(FixedWidth.Double);
}
示例3: WriteFloat
public static void WriteFloat(ByteBuffer buffer, float data)
{
buffer.EnsureSize(FixedWidth.Float);
fixed (byte* d = &buffer.Buffer[buffer.End])
{
byte* p = (byte*)&data;
d[0] = p[3];
d[1] = p[2];
d[2] = p[1];
d[3] = p[0];
}
buffer.Append(FixedWidth.Float);
}
示例4: WriteUShort
public static void WriteUShort(ByteBuffer buffer, ushort data)
{
buffer.EnsureSize(FixedWidth.UShort);
fixed (byte* d = &buffer.Buffer[buffer.End])
{
byte* p = (byte*)&data;
d[0] = p[1];
d[1] = p[0];
}
buffer.Append(FixedWidth.UShort);
}
示例5: WriteUByte
public static void WriteUByte(ByteBuffer buffer, byte data)
{
buffer.EnsureSize(FixedWidth.UByte);
buffer.Buffer[buffer.End] = data;
buffer.Append(FixedWidth.UByte);
}
示例6: Encode
static void Encode(AmqpSymbol value, int width, ByteBuffer buffer)
{
int stringSize = Encoding.ASCII.GetByteCount(value.Value);
if (width == 0)
{
width = AmqpEncoding.GetEncodeWidthBySize(stringSize);
}
if (width == FixedWidth.UByte)
{
AmqpBitConverter.WriteUByte(buffer, (byte)FormatCode.Symbol8);
AmqpBitConverter.WriteUByte(buffer, (byte)stringSize);
}
else
{
AmqpBitConverter.WriteUByte(buffer, (byte)FormatCode.Symbol32);
AmqpBitConverter.WriteUInt(buffer, (uint)stringSize);
}
buffer.EnsureSize(stringSize);
int written = Encoding.ASCII.GetBytes(value.Value, 0, value.Value.Length, buffer.Buffer, buffer.End);
buffer.Append(written);
}