/// <summary> /// Renames the specified serial device, only if there is not already another serial device with the specified name. /// </summary> /// <param name="device">The device to be renamed.</param> /// <param name="newName">The new name for the device.</param> private static void RenameDevice(SerialDevice device, string newName) { // Make sure this port isn't already opened by another device foreach (SerialDevice t in _serialDevices) { if (t.Port.Equals(newName, StringComparison.OrdinalIgnoreCase)) { return; } } device.Port = newName; device.SetName(newName); }
/// <summary> /// Renames the specified serial device, only if there is not already another serial device with the specified name. /// </summary> /// <param name="device">The device to be renamed.</param> /// <param name="newName">The new name for the device.</param> private static void RenameDevice(SerialDevice device, string newName) { // Make sure this port isn't already opened by another device for (int existingDevice = 0; existingDevice < _SerialDevices.Count; existingDevice++) { if (_SerialDevices[existingDevice].Port.Equals(newName, StringComparison.OrdinalIgnoreCase)) { return; } } device.Port = newName; device.SetName(newName); }