/// <summary> /// Append a specified Init32 type value into the buffer with the specified bit length. /// </summary> /// <param name="value">Specify the value which needs to be appended.</param> /// <param name="length">Specify the bit length which the value will occupy in the buffer.</param> public void AppendInit32(int value, int length) { byte[] convertedBytes = LittleEndianBitConverter.GetBytes(value); this.SetBytes(convertedBytes, length); }
/// <summary> /// This method is used to convert the element into a byte List /// </summary> /// <returns>Return the Byte List</returns> public List <byte> SerializeToByteList() { this.RequestStart = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.Request, 0); this.UserAgentStart = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.UserAgent, 0); this.UserAgentGUID = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.UserAgentGUID, 16); this.UserAgentVersion = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.UserAgentversion, 4); this.UserAgentEnd = new StreamObjectHeaderEnd16bit((int)StreamObjectTypeHeaderEnd.UserAgent); this.CellRequestEnd = new StreamObjectHeaderEnd16bit((int)StreamObjectTypeHeaderEnd.Request); List <byte> byteList = new List <byte>(); // Protocol Version byteList.AddRange(LittleEndianBitConverter.GetBytes(this.ProtocolVersion)); // Minimum Version byteList.AddRange(LittleEndianBitConverter.GetBytes(this.MinimumVersion)); // Signature byteList.AddRange(LittleEndianBitConverter.GetBytes(this.Signature)); // Request Start byteList.AddRange(this.RequestStart.SerializeToByteList()); // User Agent Start byteList.AddRange(this.UserAgentStart.SerializeToByteList()); // User Agent GUID byteList.AddRange(this.UserAgentGUID.SerializeToByteList()); // GUID byteList.AddRange(this.GUID.ToByteArray()); // User Agent Version byteList.AddRange(this.UserAgentVersion.SerializeToByteList()); // Version byteList.AddRange(LittleEndianBitConverter.GetBytes(this.Version)); // User Agent End byteList.AddRange(this.UserAgentEnd.SerializeToByteList()); if (this.IsRequestHashingOptionsUsed) { List <byte> hashSchemaList = this.RequestHashingSchema.SerializeToByteList(); this.RequestHashingOptionsDeclaration = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.RequestHashOptions, hashSchemaList.Count + 1); // Request Hashing Options Declaration byteList.AddRange(this.RequestHashingOptionsDeclaration.SerializeToByteList()); // Request Hashing Schema byteList.AddRange(hashSchemaList); // Reserve BitWriter bw = new BitWriter(1); bw.AppendInit32(this.Reserve1, 1); bw.AppendInit32(this.Reserve2, 1); bw.AppendInit32(this.RequestDataElementHashesInsteadofData, 1); bw.AppendInit32(this.RequestDataElementHashes, 1); bw.AppendInit32(this.Reserve3, 4); byteList.AddRange(bw.Bytes); } // Sub-requests if (this.SubRequests != null && this.SubRequests.Count != 0) { foreach (FsshttpbCellSubRequest subRequest in this.SubRequests) { byteList.AddRange(subRequest.SerializeToByteList()); } } else { throw new InvalidOperationException("MUST contain sub request in request structure which is defined in the MS-FSSHTTPB."); } // Data Element Package if (this.DataElementPackage != null) { byteList.AddRange(this.DataElementPackage.SerializeToByteList()); } // Cell Request End byteList.AddRange(this.CellRequestEnd.SerializeToByteList()); return(byteList); }
/// <summary> /// Append a specified Unit64 type value into the buffer with the specified bit length. /// </summary> /// <param name="value">Specify the value which needs to be appended.</param> /// <param name="length">Specify the bit length which the value will occupy in the buffer.</param> public void AppendUInt64(ulong value, int length) { byte[] convertedBytes = LittleEndianBitConverter.GetBytes(value); this.SetBytes(convertedBytes, length); }
/// <summary> /// Used to convert the element into a byte List. /// </summary> /// <param name="byteList">A Byte list</param> /// <returns>A constant value 8</returns> protected override int SerializeItemsToByteList(List <byte> byteList) { byteList.AddRange(LittleEndianBitConverter.GetBytes(this.DataSize)); return(8); }