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


C# ByteBuffer.EnsureLength方法代碼示例

本文整理匯總了C#中System.ByteBuffer.EnsureLength方法的典型用法代碼示例。如果您正苦於以下問題:C# ByteBuffer.EnsureLength方法的具體用法?C# ByteBuffer.EnsureLength怎麽用?C# ByteBuffer.EnsureLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.EnsureLength方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ReadUByte

 public static byte ReadUByte(ByteBuffer buffer)
 {
     buffer.EnsureLength(FixedWidth.UByte);
     byte data = buffer.Buffer[buffer.Offset];
     buffer.Complete(FixedWidth.UByte);
     return data;
 }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:7,代碼來源:AmqpBitConverter.cs

示例2: ReadUShort

        public static ushort ReadUShort(ByteBuffer buffer)
        {
            buffer.EnsureLength(FixedWidth.UShort);
            ushort data;
            fixed (byte* p = &buffer.Buffer[buffer.Offset])
            {
                byte* d = (byte*)&data;
                d[0] = p[1];
                d[1] = p[0];
            }

            buffer.Complete(FixedWidth.UShort);
            return data;
        }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:14,代碼來源:AmqpBitConverter.cs

示例3: ReadUInt

        public static uint ReadUInt(ByteBuffer buffer)
        {
            buffer.EnsureLength(FixedWidth.UInt);
            uint data;
            fixed (byte* p = &buffer.Buffer[buffer.Offset])
            {
                byte* d = (byte*)&data;
                d[0] = p[3];
                d[1] = p[2];
                d[2] = p[1];
                d[3] = p[0];
            }

            buffer.Complete(FixedWidth.UInt);
            return data;
        }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:16,代碼來源:AmqpBitConverter.cs

示例4: ReadUuid

        public static Guid ReadUuid(ByteBuffer buffer)
        {
            buffer.EnsureLength(FixedWidth.Uuid);
            Guid data;
            fixed (byte* p = &buffer.Buffer[buffer.Offset])
            {
                byte* d = (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.Complete(FixedWidth.Uuid);
            return data;
        }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:24,代碼來源:AmqpBitConverter.cs

示例5: ReadDouble

        public static double ReadDouble(ByteBuffer buffer)
        {
            buffer.EnsureLength(FixedWidth.Double);
            double data;
            fixed (byte* p = &buffer.Buffer[buffer.Offset])
            {
                byte* d = (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.Complete(FixedWidth.Double);
            return data;
        }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:20,代碼來源:AmqpBitConverter.cs

示例6: ReadULong

 public static ulong ReadULong(ByteBuffer buffer)
 {
     buffer.EnsureLength(FixedWidth.ULong);
     ulong data = ReadULong(buffer.Buffer, buffer.Offset, buffer.Length);
     buffer.Complete(FixedWidth.ULong);
     return data;
 }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:7,代碼來源:AmqpBitConverter.cs

示例7: OnReadObject

            protected override object OnReadObject(ByteBuffer buffer)
            {
                object container = Activator.CreateInstance(this.type);
                FormatCode formatCode = AmqpEncoding.ReadFormatCode(buffer);    // FormatCode.Described
                if (formatCode != FormatCode.Described)
                {
                    throw new AmqpException(AmqpError.InvalidField, "format-code");
                }

                bool validDescriptor = false;
                formatCode = AmqpEncoding.ReadFormatCode(buffer);
                if (formatCode == FormatCode.ULong || formatCode == FormatCode.SmallULong)
                {
                    ulong code = AmqpBitConverter.ReadULong(buffer);
                    validDescriptor = this.descriptorCode == null || code == this.descriptorCode.Value;
                }
                else if (formatCode == FormatCode.Symbol8 || formatCode == FormatCode.Symbol32)
                {
                    AmqpSymbol symbol = SymbolEncoding.Decode(buffer, formatCode);
                    validDescriptor = this.descriptorName.Value == null || symbol.Equals(this.descriptorName);
                }

                if (!validDescriptor)
                {
                    throw new AmqpException(AmqpError.InvalidField, "descriptor");
                }

                formatCode = AmqpEncoding.ReadFormatCode(buffer);    // FormatCode.List
                if (formatCode == FormatCode.List0)
                {
                    return container;
                }

                int size = 0;
                int count = 0;
                AmqpEncoding.ReadSizeAndCount(buffer, formatCode, FormatCode.List8, FormatCode.List32, out size, out count);

                // prefetch bytes from the stream
                buffer.EnsureLength(size - FixedWidth.UInt);
                for (int i = 0; i < count; ++i)
                {
                    object value = this.members[i].Type.OnReadObject(buffer);
                    this.members[i].Accessor.SetObject(container, value);
                }

                return container;
            }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:47,代碼來源:SerializableType.cs


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