當前位置: 首頁>>代碼示例>>C#>>正文


C# ByteBuffer.EnsureSize方法代碼示例

本文整理匯總了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);
        }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:22,代碼來源:AmqpBitConverter.cs

示例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);
        }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:18,代碼來源:AmqpBitConverter.cs

示例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);
        }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:14,代碼來源:AmqpBitConverter.cs

示例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);
        }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:12,代碼來源:AmqpBitConverter.cs

示例5: WriteUByte

 public static void WriteUByte(ByteBuffer buffer, byte data)
 {
     buffer.EnsureSize(FixedWidth.UByte);
     buffer.Buffer[buffer.End] = data;
     buffer.Append(FixedWidth.UByte);
 }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:6,代碼來源:AmqpBitConverter.cs

示例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);
        }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:23,代碼來源:SymbolEncoding.cs


注:本文中的System.ByteBuffer.EnsureSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。