/// <summary> /// Disposes a device, passing feedback to the console. Logs an error if it fails. /// </summary> /// <param name="device">The device to dispose.</param> /// <param name="deviceDescriptor">A description of the device for use in the console and error log.</param> public static void Dispose(this GenericBase device, string deviceDescriptor) { try { if (device == null) { CrestronConsole.PrintLine("Couldn't dispose {0}, the device was null.", deviceDescriptor); ErrorLog.Error("Couldn't dispose {0}, the device was null.", deviceDescriptor); return; } device.Dispose(); CrestronConsole.PrintLine("Disposed of the {0}", deviceDescriptor); } catch (Exception ex) { CrestronConsole.PrintLine("The device {0} potentially failed to dispose, due to an exception: {1}", deviceDescriptor, ex.Message); ErrorLog.Error("The device {0} potentially failed to dispose, due to an exception: {1}", deviceDescriptor, ex.Message); } }