示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
 public static bool IsPortRecordRegistered(PortRecord record)
 => CustomPorts.AllItems.Contains(record) || ComputerExtensions.OGPorts.ContainsValue(record);
示例#4
0
 internal static void RegisterPortInternal(PortRecord info, Assembly portAsm)
 {
     CustomPorts.Add(info, portAsm);
 }
示例#5
0
 public static void RegisterPort(PortRecord record) => RegisterPortInternal(record, Assembly.GetCallingAssembly());
示例#6
0
 public static bool RemovePort(this Computer comp, PortRecord record)
 {
     return(comp.RemovePort(record.Protocol));
 }