/// <summary> /// Constructor /// </summary> /// <param name="testsuiteId">Instance of <see cref="Microsoft.Protocols.TestManager.RDPClientPlugin.SUTControl_TestsuiteId" /> Test suite id. </param> /// <param name="commandId">Instance of <see cref="Microsoft.Protocols.TestManager.RDPClientPlugin.RDPSUTControl_CommandId" /> Command to execute.</param> /// <param name="caseName">Case name</param> /// <param name="requestId">Request id</param> /// <param name="helpMessage">Help message</param> /// <param name="payload">Connection payload</param> public SUT_Control_Request_Message(SUTControl_TestsuiteId testsuiteId, ushort commandId, string caseName, ushort requestId, string helpMessage, byte[] payload) { this.messageType = SUTControl_MessageType.SUT_CONTROL_REQUEST; this.testsuiteId = testsuiteId; this.commandId = commandId; this.caseNameLength = 0; this.caseName = caseName; if (!string.IsNullOrEmpty(this.caseName)) { this.caseNameLength = (uint)Encoding.UTF8.GetByteCount(this.caseName); } this.requestId = requestId; this.helpMessageLength = 0; this.helpMessage = helpMessage; if (helpMessage != null) { this.helpMessageLength = (uint)Encoding.UTF8.GetByteCount(helpMessage); } this.payloadLength = 0; this.payload = payload; if (payload != null) { this.payloadLength = (uint)payload.Length; } }
/// <summary> /// Constructor /// </summary> /// <param name="testsuiteId">Instance of <see cref="Microsoft.Protocols.TestManager.RDPClientPlugin.SUTControl_TestsuiteId" /> Test suite id. </param> /// <param name="commandId">Instance of <see cref="Microsoft.Protocols.TestManager.RDPClientPlugin.RDPSUTControl_CommandId" /> Command to execute.</param> /// <param name="requestId">Request id</param> /// <param name="errorMessage">Error message</param> /// <param name="payload">Connection payload</param> public SUT_Control_Response_Message(SUTControl_TestsuiteId testsuiteId, ushort commandId, string caseName, ushort requestId, uint resultCode, string errorMessage, byte[] payload) { this.messageType = SUTControl_MessageType.SUT_CONTROL_RESPONSE; this.testsuiteId = testsuiteId; this.commandId = commandId; this.caseNameLength = 0; this.caseName = caseName; if (!string.IsNullOrEmpty(this.caseName)) { this.caseNameLength = (uint)Encoding.UTF8.GetByteCount(this.caseName); } this.requestId = requestId; this.resultCode = resultCode; this.errorMessageLength = 0; this.errorMessage = errorMessage; if (errorMessage != null) { this.errorMessageLength = (uint)Encoding.UTF8.GetByteCount(errorMessage); } this.payloadLength = 0; this.payload = payload; if (payload != null) { this.payloadLength = (uint)payload.Length; } }
/// <summary> /// Decode method /// </summary> /// <param name="rawData">Decode source binary data</param> /// <param name="index">Decode position</param> /// <returns>Is decode success</returns> public bool Decode(byte[] rawData, ref int index) { try { this.messageType = (SUTControl_MessageType)BitConverter.ToUInt16(Utility.GetNumericBytes(rawData, index, 2), 0); index += 2; this.testsuiteId = (SUTControl_TestsuiteId)BitConverter.ToUInt16(Utility.GetNumericBytes(rawData, index, 2), 0); index += 2; this.commandId = BitConverter.ToUInt16(Utility.GetNumericBytes(rawData, index, 2), 0); index += 2; this.caseNameLength = BitConverter.ToUInt32(Utility.GetNumericBytes(rawData, index, 4), 0); index += 4; if (this.caseNameLength > 0) { int size = (int)caseNameLength; this.caseName = Encoding.UTF8.GetString(rawData, index, size); index += size; } this.requestId = BitConverter.ToUInt16(Utility.GetNumericBytes(rawData, index, 2), 0); index += 2; this.resultCode = BitConverter.ToUInt32(Utility.GetNumericBytes(rawData, index, 4), 0); index += 4; this.errorMessageLength = BitConverter.ToUInt32(Utility.GetNumericBytes(rawData, index, 4), 0); index += 4; if (errorMessageLength > 0) { int size = (int)errorMessageLength; this.errorMessage = Encoding.UTF8.GetString(rawData, index, size); index += size; } this.payloadLength = BitConverter.ToUInt32(Utility.GetNumericBytes(rawData, index, 4), 0); index += 4; if (payloadLength > 0) { this.payload = new byte[payloadLength]; Array.Copy(rawData, index, payload, 0, payloadLength); index += (int)payloadLength; } return(true); } catch { return(false); } }
/// <summary> /// Constructor /// </summary> /// <param name="testsuiteId"></param> /// <param name="commandId"></param> /// <param name="requestId"></param> /// <param name="helpMessage"></param> /// <param name="payload"></param> public SUT_Control_Request_Message(SUTControl_TestsuiteId testsuiteId, ushort commandId, ushort requestId, string helpMessage, byte[] payload) { this.messageType = SUTControl_MessageType.SUT_CONTROL_REQUEST; this.testsuiteId = testsuiteId; this.commandId = commandId; this.requestId = requestId; this.helpMessageLength = 0; this.helpMessage = helpMessage; if (helpMessage != null) { this.helpMessageLength = (uint)Encoding.UTF8.GetByteCount(helpMessage); } this.payloadLength = 0; this.payload = payload; if (payload != null) { this.payloadLength = (uint)payload.Length; } }
/// <summary> /// Decode method /// </summary> /// <param name="marshaler"></param> /// <returns></returns> public bool Decode(byte[] rawData, ref int index) { try { this.messageType = (SUTControl_MessageType)BitConverter.ToUInt16(Utility.GetNumericBytes(rawData, index, 2), 0); index += 2; this.testsuiteId = (SUTControl_TestsuiteId)BitConverter.ToUInt16(Utility.GetNumericBytes(rawData, index, 2), 0); index += 2; this.commandId = BitConverter.ToUInt16(Utility.GetNumericBytes(rawData, index, 2), 0); index += 2; this.requestId = BitConverter.ToUInt16(Utility.GetNumericBytes(rawData, index, 2), 0); index += 2; this.resultCode = BitConverter.ToUInt32(Utility.GetNumericBytes(rawData, index, 4), 0); index += 4; this.errorMessageLength = BitConverter.ToUInt32(Utility.GetNumericBytes(rawData, index, 4), 0); index += 4; if (errorMessageLength > 0) { int size = (int)errorMessageLength; this.errorMessage = Encoding.UTF8.GetString(rawData, index, size); index += size; } this.payloadLength = BitConverter.ToUInt32(Utility.GetNumericBytes(rawData, index, 4), 0); index += 4; if (payloadLength > 0) { this.payload = new byte[payloadLength]; Array.Copy(rawData, index, payload, 0, payloadLength); index += (int)payloadLength; } return true; } catch { return false; } }
/// <summary> /// Constructor /// </summary> /// <param name="testsuiteId"></param> /// <param name="commandId"></param> /// <param name="requestId"></param> /// <param name="errorMessage"></param> /// <param name="payload"></param> public SUT_Control_Response_Message(SUTControl_TestsuiteId testsuiteId, ushort commandId, ushort requestId, uint resultCode, string errorMessage, byte[] payload) { this.messageType = SUTControl_MessageType.SUT_CONTROL_RESPONSE; this.testsuiteId = testsuiteId; this.commandId = commandId; this.requestId = requestId; this.resultCode = resultCode; this.errorMessageLength = 0; this.errorMessage = errorMessage; if (errorMessage != null) { this.errorMessageLength = (uint)Encoding.UTF8.GetByteCount(errorMessage); } this.payloadLength = 0; this.payload = payload; if (payload != null) { this.payloadLength = (uint)payload.Length; } }