Microsoft.Protocols.TestSuites.SharedAdapter.StreamObjectHeaderEnd16bit.DoDeserializeFromByteArray C# (CSharp) Method

DoDeserializeFromByteArray() protected method

This method is used to deserialize the StreamObjectHeaderEnd16bit basic object from the specified byte array and start index.
protected DoDeserializeFromByteArray ( byte byteArray, int startIndex ) : int
byteArray byte Specify the byte array.
startIndex int Specify the start index from the byte array.
return int
        protected override int DoDeserializeFromByteArray(byte[] byteArray, int startIndex)
        {
            using (BitReader reader = new BitReader(byteArray, startIndex))
            {
                int headerType = reader.ReadInt32(2);

                if (headerType != 0x3)
                {
                    throw new InvalidOperationException(string.Format("Failed to get the StreamObjectHeaderEnd16bit header type value, expect value {0}, but actual value is {1}", 0x3, headerType));
                }

                uint typeValue = reader.ReadUInt32(14);
                if (!Enum.IsDefined(typeof(StreamObjectTypeHeaderEnd), (int)typeValue))
                {
                    throw new InvalidOperationException(string.Format("Failed to get the StreamObjectHeaderEnd16bit type value, the value {0} is not defined", typeValue));
                }

                this.Type = (StreamObjectTypeHeaderEnd)typeValue;
                return 2;
            }
        }
    }