public void SendRequest(MessageOperationCode code, MessageSubCode subCode, [CanBeNull] params object[] parameters) { var request = new OperationRequest() { OperationCode = (byte)code, Parameters = new Dictionary <byte, object>() { { (byte)MessageParameterCode.SubCodeParameterCode, subCode } } }; //all paramters as pairs of 2 if (parameters != null) { for (int i = 0; i < parameters.Length; i += 2) { // if (!(parameters[i] is MessageParameterCode)) { throw new ArgumentException(string.Format("Paramter {0} is not a MessageParamterCode", i)); } //add the pairs request.Parameters.Add((byte)parameters[i], parameters[i + 1]); } } //original send request SendRequest(request); }
public void SendRequest(MessageOperationCode code, MessageSubCode subCode, params object[] parameters) { var request = new OperationRequest() { OperationCode = (byte)code, Parameters = new Dictionary <byte, object>() { { (byte)MessageParameterCode.SubCodeParameterCode, subCode } } }; // Go through all parameters as pairs of 2 for (int i = 0; i < parameters.Length; i += 2) { // Make sure the first in each pair is a ParameterCode if (!(parameters[i] is MessageParameterCode)) { throw new ArgumentException(string.Format("Parameter {0} is not a MessageParameterCode", i)); } // Add the pairs request.Parameters.Add((byte)parameters[i], parameters[i + 1]); } // Send the Request SendRequest(request); }