当前位置: 首页>>代码示例>>C#>>正文


C# ByteBuffer.Complete方法代码示例

本文整理汇总了C#中ByteBuffer.Complete方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.Complete方法的具体用法?C# ByteBuffer.Complete怎么用?C# ByteBuffer.Complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.Complete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Decode

        public static string Decode(ByteBuffer buffer, FormatCode formatCode)
        {
            if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null)
            {
                return null;
            }

            int count;
            Encoding encoding;

            if (formatCode == FormatCode.String8Utf8)
            {
                count = (int)AmqpBitConverter.ReadUByte(buffer);
                encoding = Encoding.UTF8;
            }
            else if (formatCode == FormatCode.String32Utf8)
            {
                count = (int)AmqpBitConverter.ReadUInt(buffer);
                encoding = Encoding.UTF8;
            }
            else
            {
                throw AmqpEncoding.GetEncodingException(AmqpResources.GetString(AmqpResources.AmqpInvalidFormatCode, formatCode, buffer.Offset));
            }

            string value = encoding.GetString(buffer.Buffer, buffer.Offset, count);
            buffer.Complete(count);

            return value;
        }
开发者ID:Azure,项目名称:azure-amqp,代码行数:30,代码来源:StringEncoding.cs

示例2: Decode

        public static AmqpSymbol Decode(ByteBuffer buffer, FormatCode formatCode)
        {
            if (formatCode == 0 && (formatCode = AmqpEncoding.ReadFormatCode(buffer)) == FormatCode.Null)
            {
                return new AmqpSymbol();
            }

            int count;
            AmqpEncoding.ReadCount(buffer, formatCode, FormatCode.Symbol8, FormatCode.Symbol32, out count);
            string value = Platform.System.Text.Encoding.ASCII.GetString(buffer.Buffer, buffer.Offset, count);
            buffer.Complete(count);

            return new AmqpSymbol(value);
        }
开发者ID:Azure,项目名称:azure-amqp,代码行数:14,代码来源:SymbolEncoding.cs

示例3: DecodeValue

        public override void DecodeValue(ByteBuffer buffer)
        {
            FormatCode formatCode = AmqpEncoding.ReadFormatCode(buffer);
            if (formatCode == FormatCode.List0)
            {
                return;
            }

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

            int extraCount = count - this.FieldCount;
            if (extraCount > 0)
            {
                // we just ignore the rest of bytes. ideally we should decode the remaining objects
                // to validate the buffer contains valid AMQP objects.
                int bytesRemaining = size - (buffer.Offset - offset) - (formatCode == FormatCode.List8 ? FixedWidth.UByte : FixedWidth.UInt);
                buffer.Complete(bytesRemaining);
            }
        }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:24,代码来源:DescribedList.cs

示例4: DecodeValue

        internal override void DecodeValue(ByteBuffer buffer)
        {
            // initialize the value buffer only
            int offset = buffer.Offset;
            byte formatCode = Encoder.ReadFormatCode(buffer);
            while (formatCode == FormatCode.Described)
            {
                Encoder.ReadObject(buffer);
                formatCode = Encoder.ReadFormatCode(buffer);
            }

            int count = this.GetCount(formatCode, buffer);
            buffer.Validate(false, count);
            buffer.Complete(count);

            int size = buffer.Offset - offset;
            this.valueBuffer = new ByteBuffer(buffer.Buffer, offset, size, size);
        }
开发者ID:Eclo,项目名称:amqpnetlite,代码行数:18,代码来源:AmqpValue.cs


注:本文中的ByteBuffer.Complete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。