Microsoft.Protocols.TestSuites.Common.BufferReader.ReadUInt16 C# (CSharp) Method

ReadUInt16() public method

Reads a 2-byte unsigned integer from the current position and advances the current position of the buffer by 2 bytes.
public ReadUInt16 ( ) : ushort
return ushort
        public ushort ReadUInt16()
        {
            if (this.position + 1 >= this.length)
            {
                throw new Exception("bufferReader out of bound.");
            }

            short low = (short)this.buffer[this.position++];
            short high = (short)(this.buffer[this.position++] << 8);
            return (ushort)(low + high);
        }

Usage Example

コード例 #1
0
        /// <summary>
        /// Deserialized byte array to a Restriction instance
        /// </summary>
        /// <param name="buffer">Byte array contain data of a Restriction instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public override uint Deserialize(byte[] buffer)
        {
            BufferReader reader = new BufferReader(buffer);
            this.RestrictType = (RestrictionType)reader.ReadByte();
            this.propTag.PropertyType = reader.ReadUInt16();
            this.propTag.PropertyId = reader.ReadUInt16();

            return reader.Position;
        }
All Usage Examples Of Microsoft.Protocols.TestSuites.Common.BufferReader::ReadUInt16