public PortDefinition[] GetPersistablePortDefinitions() { PortDefinition[] ports = null; switch (m_portFilter) { case PortFilter.Emulator: Debug.Assert(false); break; case PortFilter.Serial: ports = AsyncSerialStream.EnumeratePorts(); break; case PortFilter.Usb: { if (MonoDevelop.Core.Platform.IsWindows) { PortDefinition[] portUSB; PortDefinition[] portWinUSB; portUSB = AsyncUsbStream.EnumeratePorts(); portWinUSB = WinUsb_AsyncUsbStream.EnumeratePorts(); int lenUSB = portUSB != null ? portUSB.Length : 0; int lenWinUSB = portWinUSB != null ? portWinUSB.Length : 0; ports = new PortDefinition[lenUSB + lenWinUSB]; if (lenUSB > 0) { Array.Copy(portUSB, ports, lenUSB); } if (lenWinUSB > 0) { Array.Copy(portWinUSB, 0, ports, lenUSB, lenWinUSB); } } else { ports = LibUsb_AsyncUsbStream.EnumeratePorts(); } } break; case PortFilter.TcpIp: ports = PortDefinition_Tcp.EnumeratePorts(false); break; default: Debug.Assert(false); throw new ApplicationException(); } return(ports); }
static public ArrayList Enumerate(params PortFilter[] args) { ArrayList lst = new ArrayList(); foreach (PortFilter pf in args) { PortDefinition[] res; switch (pf) { case PortFilter.Emulator: res = Emulator.EnumeratePipes(); break; case PortFilter.Serial: res = AsyncSerialStream.EnumeratePorts(); break; case PortFilter.LegacyPermiscuousWinUsb: case PortFilter.Usb: { res = WinUsb_AsyncUsbStream.EnumeratePorts(pf == PortFilter.LegacyPermiscuousWinUsb); lst.AddRange(res); res = AsyncUsbStream.EnumeratePorts(); // res will be added to list below... } break; case PortFilter.TcpIp: res = PortDefinition_Tcp.EnumeratePorts(); break; default: res = null; break; } if (res != null) { lst.AddRange(res); } } return(lst); }