// TODO: add a format "short" defined as (device.UsbHub + "Port " + device.UsbPort) or simply ( Hub X Port Y) public string ToString(String format, IFormatProvider formatProvider) { String str = null; if (format == "P") { // Format simply as Port X str = String.Format("Port {0}", Index); } else if (format == "ID") { // Format as Hub X Port Y str = String.Format("Hub {0} Port {1}", this.Hub.Index, this.Index); } else if (format == "D") { // Format as Port X - Device.ToString() str = String.Format("Port {0} - {1}", Index, AttachedDevice.ToString()); } else if (format == "H") { // If the connection is to a hub, format Port X - Hub Y UsbHub hub = AttachedDevice as UsbHub; str = String.Format("Port {0} - Hub {1}", Index, hub.Index); } else if (format == "E") { // Format as Port X [ConnectionStatus] Device.ToString() str = String.Format("Port {0} [{1}] {2}", Index, NodeConnectionInfo.ConnectionStatus, AttachedDevice.ToString()); } else if (format == "U") { // Format as Port X [ConnectionStatus] UNKNOWN str = String.Format("Port {0} [{1}] UNKNOWN", Index, NodeConnectionInfo.ConnectionStatus); } else { str = ToString(); } return(str); }
void IDisposable.Dispose() { TcpClient.Dispose(); AttachedDevice?.Dispose(); }