public Task SendSystemCommand(SystemCommand command, CancellationToken cancellationToken) { switch (command) { case SystemCommand.VolumeDown: return(_device.VolumeDown()); case SystemCommand.VolumeUp: return(_device.VolumeUp()); case SystemCommand.Mute: return(_device.VolumeDown(true)); case SystemCommand.Unmute: return(_device.VolumeUp(true)); case SystemCommand.ToggleMute: return(_device.ToggleMute()); default: return(Task.FromResult(true)); } }
public Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken) { GeneralCommandType commandType; if (Enum.TryParse(command.Name, true, out commandType)) { switch (commandType) { case GeneralCommandType.VolumeDown: return(_device.VolumeDown()); case GeneralCommandType.VolumeUp: return(_device.VolumeUp()); case GeneralCommandType.Mute: return(_device.Mute()); case GeneralCommandType.Unmute: return(_device.Unmute()); case GeneralCommandType.ToggleMute: return(_device.ToggleMute()); case GeneralCommandType.SetVolume: { string volumeArg; if (command.Arguments.TryGetValue("Volume", out volumeArg)) { int volume; if (int.TryParse(volumeArg, NumberStyles.Any, _usCulture, out volume)) { return(_device.SetVolume(volume)); } throw new ArgumentException("Unsupported volume value supplied."); } throw new ArgumentException("Volume argument cannot be null"); } default: return(Task.FromResult(true)); } } return(Task.FromResult(true)); }