/// <summary> /// Deserialize items from byte array. /// </summary> /// <param name="byteArray">The byte array which contains response message.</param> /// <param name="currentIndex">The index special where to start.</param> /// <param name="lengthOfItems">The length of items.</param> protected override void DeserializeItemsFromByteArray(byte[] byteArray, ref int currentIndex, int lengthOfItems) { int index = currentIndex; this.RequestID = BasicObject.Parse <Compact64bitInt>(byteArray, ref index); this.RequestType = BasicObject.Parse <Compact64bitInt>(byteArray, ref index); this.Status = (byteArray[index] & 0x1) == 0x1 ? true : false; this.Reserved = (byte)(byteArray[index] >> 1); index += 1; if (index - currentIndex != lengthOfItems) { throw new ResponseParseErrorException(currentIndex, "CellSubResponse object over-parse error", null); } if (this.Status) { this.ResponseError = StreamObject.GetCurrent <ResponseError>(byteArray, ref index); } else { this.SubResponseData = SubResponseData.GetCurrentSubResponseData((int)this.RequestType.DecodedValue, byteArray, ref index); if (SharedContext.Current.IsMsFsshttpRequirementsCaptured) { // Capture the requirements related response data. new MsfsshttpbAdapterCapture().InvokeCaptureMethod(this.SubResponseData.GetType(), this.SubResponseData, SharedContext.Current.Site); } } currentIndex = index; }
/// <summary> /// Get current sub response data. /// </summary> /// <param name="type">The type that want to get.</param> /// <param name="byteArray">The byte array.</param> /// <param name="startIndex">The position where to start.</param> /// <returns>The instance of sub response data.</returns> public static SubResponseData GetCurrentSubResponseData(int type, byte[] byteArray, ref int startIndex) { int index = startIndex; if (!SubResponseDataTypeMapping.Keys.Contains(type)) { throw new ResponseParseErrorException(-1, "Unexpected sub response type value" + type, null); } SubResponseData subResponseData = Activator.CreateInstance(SubResponseDataTypeMapping[type]) as SubResponseData; subResponseData.DeserializeSubResponseDataFromByteArray(byteArray, ref index); startIndex = index; return(subResponseData); }