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


C# ByteBuffer.Complete方法代碼示例

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


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

示例1: Encode

        public static ByteBuffer Encode(FrameType type, ushort channel, Transfer transfer,
            ByteBuffer payload, int maxFrameSize, out int payloadSize)
        {
            int bufferSize = cmdBufferSize + payload.Length;
            if (bufferSize > maxFrameSize)
            {
                bufferSize = maxFrameSize;
            }

            bool more = false;   // estimate it first
            if (payload.Length > bufferSize - 32)
            {
                transfer.More = more = true;
            }

            ByteBuffer buffer = new ByteBuffer(bufferSize, false);
            EncodeFrame(buffer, type, channel, transfer);

            if (more && payload.Length <= buffer.Size)
            {
                // guessed it wrong. correct it
                transfer.More = false;
                buffer.Reset();
                EncodeFrame(buffer, type, channel, transfer);
            }

            payloadSize = Math.Min(payload.Length, buffer.Size);
            AmqpBitConverter.WriteBytes(buffer, payload.Buffer, payload.Offset, payloadSize);
            payload.Complete(payloadSize);
            AmqpBitConverter.WriteInt(buffer.Buffer, 0, buffer.Length);
            return buffer;
        }
開發者ID:rajeshganesh,項目名稱:amqpnetlite,代碼行數:32,代碼來源:Frame.cs

示例2: ReadByte

 public static sbyte ReadByte(ByteBuffer buffer)
 {
     buffer.Validate(false, FixedWidth.Byte);
     sbyte data = (sbyte)buffer.Buffer[buffer.Offset];
     buffer.Complete(FixedWidth.Byte);
     return data;
 }
開發者ID:Azure,項目名稱:azure-amqp,代碼行數:7,代碼來源:AmqpBitConverter.cs

示例3: Decode

 public void Decode(ByteBuffer buffer)
 {
     byte[] bytes = new byte[16];
     Buffer.BlockCopy(buffer.Buffer, buffer.Offset, bytes, 0, bytes.Length);
     this.uuid = new Guid(bytes);
     buffer.Complete(bytes.Length);
 }
開發者ID:Eclo,項目名稱:amqpnetlite,代碼行數:7,代碼來源:EmployeeId.cs

示例4: 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

示例5: ReadUInt

 public static uint ReadUInt(ByteBuffer buffer)
 {
     buffer.Validate(false, FixedWidth.UInt);
     uint data = ReadUInt(buffer.Buffer, buffer.Offset, buffer.Length);
     buffer.Complete(FixedWidth.UInt);
     return data;
 }
開發者ID:Azure,項目名稱:azure-amqp,代碼行數:7,代碼來源:AmqpBitConverter.cs

示例6: Decode

        public static ArraySegment<byte> Decode(ByteBuffer buffer, FormatCode formatCode)
        {
            if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null)
            {
                return AmqpConstants.EmptyBinary;
            }

            int count;
            AmqpEncoding.ReadCount(buffer, formatCode, FormatCode.Binary8, FormatCode.Binary32, out count);
            ArraySegment<byte> value = new ArraySegment<byte>(buffer.Buffer, buffer.Offset, count);
            buffer.Complete(count);
            return value;
        }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:13,代碼來源:BinaryEncoding.cs

示例7: ReadShort

        public static short ReadShort(ByteBuffer buffer)
        {
            buffer.Validate(false, FixedWidth.Short);
            short data;
            fixed (byte* p = &buffer.Buffer[buffer.Offset])
            {
                byte* d = (byte*)&data;
                d[0] = p[1];
                d[1] = p[0];
            }

            buffer.Complete(FixedWidth.Short);
            return data;
        }
開發者ID:Azure,項目名稱:azure-amqp,代碼行數:14,代碼來源:AmqpBitConverter.cs

示例8: 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

示例9: ReadInt

        public static int ReadInt(ByteBuffer buffer)
        {
            buffer.EnsureLength(FixedWidth.Int);
            int 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.Int);
            return data;
        }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:16,代碼來源:AmqpBitConverter.cs

示例10: TryDecodeNull

 protected bool TryDecodeNull(ByteBuffer buffer)
 {
     buffer.Validate(false, FixedWidth.FormatCode);
     byte formatCode = buffer.Buffer[buffer.Offset];
     if (formatCode == FormatCode.Null)
     {
         buffer.Complete(FixedWidth.FormatCode);
         return true;
     }
     else
     {
         return false;
     }
 }
開發者ID:rajeshganesh,項目名稱:amqpnetlite,代碼行數:14,代碼來源:SerializableType.cs

示例11: DecodeHeader

        void DecodeHeader(ByteBuffer buffer)
        {
            this.Size = (int)AmqpBitConverter.ReadUInt(buffer);
            this.DataOffset = AmqpBitConverter.ReadUByte(buffer);
            this.Type = (FrameType)AmqpBitConverter.ReadUByte(buffer);
            this.Channel = AmqpBitConverter.ReadUShort(buffer);

            // skip extended header
            buffer.Complete(this.DataOffset * 4 - Frame.HeaderSize);
        }
開發者ID:Azure,項目名稱:azure-amqp,代碼行數:10,代碼來源:Frame.cs

示例12: Decode

        public static Frame Decode(ByteBuffer buffer, bool fullBody = true)
        {
            Frame frame = new Frame();
            frame.RawBuffer = buffer.Array;

            // Header
            frame.size = (int)AmqpBitConverter.ReadUInt(buffer);
            frame.dataOffset = AmqpBitConverter.ReadUByte(buffer);
            frame.Type = (FrameType)AmqpBitConverter.ReadUByte(buffer);
            frame.Channel = AmqpBitConverter.ReadUShort(buffer);
            // skip extended header
            buffer.Complete(frame.dataOffset * 4 - Frame.HeaderSize);

            // Command
            if (buffer.Length > 0)
            {
                frame.Command = (Performative)AmqpCodec.CreateAmqpDescribed(buffer);
                if (fullBody)
                {
                    frame.Command.DecodeValue(buffer);
                }
            }

            return frame;
        }
開發者ID:modulexcite,項目名稱:IL2JS,代碼行數:25,代碼來源:Frame.cs

示例13: 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

示例14: 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

示例15: ReadObject

            public override object ReadObject(ByteBuffer buffer)
            {
                FormatCode formatCode = AmqpEncoding.ReadFormatCode(buffer);
                if (formatCode == FormatCode.Null)
                {
                    return null;
                }

                int size;
                int count;
                int encodeWidth;
                Collection effectiveType;
                this.Initialize(buffer, formatCode, out size, out count, out encodeWidth, out effectiveType);
                int offset = buffer.Offset;

                object container = effectiveType.CreateInstance();
                if (count > 0)
                {
                    effectiveType.ReadMembers(buffer, container, ref count);

                    if (count > 0)
                    {
                        // skip unknow members: todo: support IExtensibleDataObject
                        buffer.Complete(size - (buffer.Offset - offset) - encodeWidth);
                    }
                }

                return container;
            }
開發者ID:Azure,項目名稱:azure-amqp,代碼行數:29,代碼來源:SerializableType.cs


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