public static void AddPort(this Computer comp, string protocol, int portNum, string displayName) { var record = PortManager.GetPortRecordFromProtocol(protocol); if (record == null) { record = new PortRecord(protocol, displayName, portNum); } comp.AddPort(record.CreateState(null, displayName, portNum)); }
public static void AddPort(this Computer comp, PortRecord record) { record.ThrowNull(nameof(record)); if (!PortManager.IsPortRecordRegistered(record)) { Logger.Log(LogLevel.Warning, $"Protocol '{record.Protocol}' not registered, please correct, this will crash in 6.0.0"); PortManager.RegisterPort(record); } comp.AddPort(record.CreateState(comp)); }
public static bool IsPortRecordRegistered(PortRecord record) => CustomPorts.AllItems.Contains(record) || ComputerExtensions.OGPorts.ContainsValue(record);
internal static void RegisterPortInternal(PortRecord info, Assembly portAsm) { CustomPorts.Add(info, portAsm); }
public static void RegisterPort(PortRecord record) => RegisterPortInternal(record, Assembly.GetCallingAssembly());
public static bool RemovePort(this Computer comp, PortRecord record) { return(comp.RemovePort(record.Protocol)); }