Microsoft.Protocols.TestSuites.MS_OXCFXICS.FastTransferStream.ReadBlocks C# (CSharp) Method

ReadBlocks() public method

Read a list of blocks and advance the position.
public ReadBlocks ( int totalSize, int blockSize ) : List
totalSize int The total number of bytes to read
blockSize int The size of each block
return List
        public List<byte[]> ReadBlocks(int totalSize, int blockSize)
        {
            int i;
            List<byte[]> l = new List<byte[]>();
            for (i = 0; i < totalSize; i += blockSize)
            {
                l.Add(this.ReadBlock(blockSize));
            }

            Debug.Assert(i == totalSize, "Assure have read all the data.");
            return l;
        }

Usage Example

        /// <summary>
        /// Deserialize next object from a FastTransferStream.
        /// </summary>
        /// <param name="stream">A FastTransferStream</param>
        public override void ConsumeNext(FastTransferStream stream)
        {
            base.ConsumeNext(stream);
            PropertyDataType type = (PropertyDataType)this.PropType;

            this.length = stream.ReadInt16();
            switch (type)
            {
            case PropertyDataType.PtypMultipleInteger16:
                this.fixedSizeValueList = stream.ReadBlocks(this.length, 2);
                break;

            case PropertyDataType.PtypMultipleInteger32:
                this.fixedSizeValueList = stream.ReadBlocks(this.length, 4);
                break;

            case PropertyDataType.PtypMultipleFloating32:
                this.fixedSizeValueList = stream.ReadBlocks(this.length, 4);
                break;

            case PropertyDataType.PtypMultipleFloating64:
                this.fixedSizeValueList = stream.ReadBlocks(this.length, 8);
                break;

            case PropertyDataType.PtypMultipleCurrency:
                this.fixedSizeValueList = stream.ReadBlocks(this.length, 8);
                break;

            case PropertyDataType.PtypMultipleFloatingTime:
                this.fixedSizeValueList = stream.ReadBlocks(this.length, 8);
                break;

            case PropertyDataType.PtypMultipleInteger64:
                this.fixedSizeValueList = stream.ReadBlocks(this.length, 8);
                break;

            case PropertyDataType.PtypMultipleTime:
                this.fixedSizeValueList = stream.ReadBlocks(this.length, 8);
                break;

            case PropertyDataType.PtypMultipleGuid:
                this.fixedSizeValueList = stream.ReadBlocks(this.length, Guid.Empty.ToByteArray().Length);
                break;

            case PropertyDataType.PtypMultipleBinary:
                this.varSizeValueList = stream.ReadLengthBlocks(this.length);
                break;

            case PropertyDataType.PtypMultipleString:
                this.varSizeValueList = stream.ReadLengthBlocks(this.length);
                break;

            case PropertyDataType.PtypMultipleString8:
                this.varSizeValueList = stream.ReadLengthBlocks(this.length);
                break;
            }
        }
All Usage Examples Of Microsoft.Protocols.TestSuites.MS_OXCFXICS.FastTransferStream::ReadBlocks