public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(base.Equals(obj));
            }

            DeviceConnection dc = (DeviceConnection)obj;

            return(device.Equals(dc.device));
        }
 public int connectToPort(Device device, short port)
 {
     lock (syncRoot)
     {
         if (deviceConnections.ContainsKey(device))
         {
             return(deviceConnections[device].connectToPort(port));
         }
         else
         {
             DeviceConnection dc = new DeviceConnection(device);
             int openedPort      = dc.connectToPort(port);
             if (openedPort > 0)
             {
                 deviceConnections.Add(device, dc);
             }
             return(openedPort);
         }
     }
 }