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

ReadToEnd() public method

Read bytes from current position to the end of buffer.
public ReadToEnd ( ) : byte[]
return byte[]
        public byte[] ReadToEnd()
        {
            byte[] byteArray = this.ReadBytes(this.length - this.position);
            return byteArray;
        }
    }

Usage Example

Ejemplo n.º 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 bufferReader = new BufferReader(buffer);
            this.RestrictType = (RestrictionType)bufferReader.ReadByte();

            uint size = bufferReader.Position;
            byte[] tmpArray = bufferReader.ReadToEnd();

            RestrictionType restrictionType = (RestrictionType)tmpArray[0];
            switch (restrictionType)
            {
                case RestrictionType.AndRestriction:
                    this.Restriction = new AndRestriction(this.CountType);
                    break;
                case RestrictionType.BitMaskRestriction:
                    this.Restriction = new BitMaskRestriction();
                    break;
                case RestrictionType.CommentRestriction:
                    this.Restriction = new CommentRestriction(this.CountType);
                    break;
                case RestrictionType.ComparePropertiesRestriction:
                    this.Restriction = new ComparePropertiesRestriction();
                    break;
                case RestrictionType.ContentRestriction:
                    this.Restriction = new ContentRestriction();
                    break;
                case RestrictionType.CountRestriction:
                    this.Restriction = new CountRestriction(this.CountType);
                    break;
                case RestrictionType.ExistRestriction:
                    this.Restriction = new ExistRestriction();
                    break;
                case RestrictionType.NotRestriction:
                    this.Restriction = new NotRestriction(this.CountType);
                    break;
                case RestrictionType.OrRestriction:
                    this.Restriction = new OrRestriction(this.CountType);
                    break;
                case RestrictionType.PropertyRestriction:
                    this.Restriction = new PropertyRestriction();
                    break;
                case RestrictionType.SizeRestriction:
                    this.Restriction = new SizeRestriction();
                    break;
                case RestrictionType.SubObjectRestriction:
                    this.Restriction = new SubObjectRestriction(this.CountType);
                    break;
            }

            size += this.Restriction.Deserialize(tmpArray);
            return size;
        }
All Usage Examples Of Microsoft.Protocols.TestSuites.Common.BufferReader::ReadToEnd