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


C# ByteBuffer.Validate方法代码示例

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


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

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

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

 public void Encode(ByteBuffer buffer)
 {
     byte[] bytes = this.uuid.ToByteArray();
     buffer.Validate(true, bytes.Length);
     Buffer.BlockCopy(bytes, 0, buffer.Buffer, buffer.WritePos, bytes.Length);
     buffer.Append(bytes.Length);
 }
开发者ID:Eclo,项目名称:amqpnetlite,代码行数:7,代码来源:EmployeeId.cs

示例4: ReadUShort

        public static ushort ReadUShort(ByteBuffer buffer)
        {
            buffer.Validate(false, 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:Azure,项目名称:azure-amqp,代码行数:14,代码来源:AmqpBitConverter.cs

示例5: ReadInt

        public static int ReadInt(ByteBuffer buffer)
        {
            buffer.Validate(false, 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:Azure,项目名称:azure-amqp,代码行数:16,代码来源:AmqpBitConverter.cs

示例6: WriteBytes

 public static void WriteBytes(ByteBuffer buffer, byte[] data, int offset, int count)
 {
     buffer.Validate(true, count);
     Buffer.BlockCopy(data, offset, buffer.Buffer, buffer.WritePos, count);
     buffer.Append(count);
 }
开发者ID:Azure,项目名称:azure-amqp,代码行数:6,代码来源:AmqpBitConverter.cs

示例7: ReadULong

 public static ulong ReadULong(ByteBuffer buffer)
 {
     buffer.Validate(false, FixedWidth.ULong);
     ulong data = ReadULong(buffer.Buffer, buffer.Offset, buffer.Length);
     buffer.Complete(FixedWidth.ULong);
     return data;
 }
开发者ID:Azure,项目名称:azure-amqp,代码行数:7,代码来源:AmqpBitConverter.cs

示例8: ReadString

        static string ReadString(ByteBuffer buffer, byte formatCode, byte code8, byte code32, string type)
        {
            if (formatCode == FormatCode.Null)
            {
                return null;
            }

            int count;
            if (formatCode == code8)
            {
                count = AmqpBitConverter.ReadUByte(buffer);
            }
            else if (formatCode == code32)
            {
                count = (int)AmqpBitConverter.ReadUInt(buffer);
            }
            else
            {
                throw DecodeException(formatCode, buffer.Offset);
            }

            buffer.Validate(false, count);
            string value = new string(Encoding.UTF8.GetChars(buffer.Buffer, buffer.Offset, count));
            buffer.Complete(count);

            return value;
        }
开发者ID:timhermann,项目名称:amqpnetlite,代码行数:27,代码来源:Encoder.cs

示例9: WriteFloat

        public static void WriteFloat(ByteBuffer buffer, float data)
        {
            buffer.Validate(true, FixedWidth.Float);
            fixed (byte* d = &buffer.Buffer[buffer.WritePos])
            {
                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:Azure,项目名称:azure-amqp,代码行数:14,代码来源:AmqpBitConverter.cs

示例10: WriteUShort

        public static void WriteUShort(ByteBuffer buffer, ushort data)
        {
            buffer.Validate(true, FixedWidth.UShort);
            fixed (byte* d = &buffer.Buffer[buffer.WritePos])
            {
                byte* p = (byte*)&data;
                d[0] = p[1];
                d[1] = p[0];
            }

            buffer.Append(FixedWidth.UShort);
        }
开发者ID:Azure,项目名称:azure-amqp,代码行数:12,代码来源:AmqpBitConverter.cs

示例11: WriteUByte

 public static void WriteUByte(ByteBuffer buffer, byte data)
 {
     buffer.Validate(true, FixedWidth.UByte);
     buffer.Buffer[buffer.WritePos] = data;
     buffer.Append(FixedWidth.UByte);
 }
开发者ID:Azure,项目名称:azure-amqp,代码行数:6,代码来源:AmqpBitConverter.cs

示例12: ReadBytes

 public static void ReadBytes(ByteBuffer buffer, byte[] data, int offset, int count)
 {
     buffer.Validate(false, count);
     Buffer.BlockCopy(buffer.Buffer, buffer.Offset, data, offset, count);
     buffer.Complete(count);
 }
开发者ID:Azure,项目名称:azure-amqp,代码行数:6,代码来源:AmqpBitConverter.cs

示例13: ReadUuid

        public static Guid ReadUuid(ByteBuffer buffer)
        {
            buffer.Validate(false, 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:Azure,项目名称:azure-amqp,代码行数:24,代码来源:AmqpBitConverter.cs

示例14: ReadDouble

        public static double ReadDouble(ByteBuffer buffer)
        {
            buffer.Validate(false, 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:Azure,项目名称:azure-amqp,代码行数:20,代码来源:AmqpBitConverter.cs

示例15: ReadBinaryBuffer

        internal static ByteBuffer ReadBinaryBuffer(ByteBuffer buffer)
        {
            byte formatCode = Encoder.ReadFormatCode(buffer);
            if (formatCode == FormatCode.Null)
            {
                return null;
            }

            int count;
            if (formatCode == FormatCode.Binary8)
            {
                count = AmqpBitConverter.ReadUByte(buffer);
            }
            else if (formatCode == FormatCode.Binary32)
            {
                count = (int)AmqpBitConverter.ReadUInt(buffer);
            }
            else
            {
                throw InvalidFormatCodeException(formatCode, buffer.Offset);
            }

            buffer.Validate(false, count);
            ByteBuffer result = new ByteBuffer(buffer.Buffer, buffer.Offset, count, count);
            buffer.Complete(count);

            return result;
        }
开发者ID:Eclo,项目名称:amqpnetlite,代码行数:28,代码来源:Encoder.cs


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