private static void SetFanSpeed(SetVerb verb) { float speed = -1; List <int> indices = verb.Fan; if (indices == null) { indices = new List <int>(); indices.Add(0); } if (verb.Auto || float.TryParse(verb.Speed, out speed)) { CallServiceMethod(client => { foreach (int idx in indices) { try { client.SetTargetFanSpeed(speed, idx); } catch (Exception e) { string msg = "Could not set fan speed"; if (!string.IsNullOrWhiteSpace(e.Message)) { msg += $": {e.Message}"; } Console.WriteLine(msg); } } }); } else { Console.Error.WriteLine("Invalid speed value"); } }
private static void SetFanSpeed(SetVerb verb) { float speed = -1; List <int> indices = verb.Fan; if (indices == null) { indices = new List <int>(); indices.Add(0); } if (verb.Auto || float.TryParse(verb.Speed, out speed)) { foreach (int idx in indices) { SetFanSpeed(speed, idx); } } else { Console.Error.WriteLine("Invalid speed value"); } }