/// <summary> /// Creates a control command from the give data type and action. /// </summary> /// <param name="dataType">Type of the data.</param> /// <param name="action">The action. Ignored if a data type of <c>Configuration</c> is used.</param> /// <returns>A control command for the given data type and action.</returns> public static IControlCommand CreateCommand(DataType dataType, ControlCommandAction action) { if (dataType == DataType.Configuration) { return new ConfigurationControlCommand(); } else { return new ControlCommand(dataType, action); } }
private void SendControlCommand(DataType dataType, ControlCommandAction action) { if (_phoneController != null && _phoneController.State == PhoneControllerState.Ready) { var command = ControlCommandFactory.CreateCommand(dataType, action); try { _phoneController.SendCommandAsync(command); } catch (Exception ex) { AddError(string.Format("Error while sending command '{0}, {1}': {2}", dataType, action, ex.Message)); } } }
/// <summary> /// Initializes a new instance of the <see cref="ControlCommand"/> class. /// </summary> /// <param name="dataType">Type of the data the command controls.</param> /// <param name="action">The action to perform, either <c>Start</c> or <c>Stop</c>.</param> public ControlCommand(DataType dataType, ControlCommandAction action) { DataType = dataType; Action = action; }