public bool IsDeviceExist(NetDeviceInfo device) { foreach (NetDeviceInfo ins in netDeviceInfoList) { if (ins.Ip.Equals(device.Ip) && ins.SN.Equals(device.SN)) { return(true); } } return(false); }
private void ProcessFindingDevice(byte[] pkg) { string message = Encoding.UTF8.GetString(pkg, 0, pkg.Length); //std_str = "myname;0002231;V1.2.3" if (message.Contains("myname")) { string[] strArray = message.Split(';'); NetDeviceInfo ndi = new NetDeviceInfo(); ndi.Ip = deviceIp; for (int a = 0; a < strArray.Length; a++) { //get sn if (a == 1) { ndi.SN = strArray[a]; } //get version if (a == 2) { ndi.Version = strArray[a];; } } if (foundNetDeviceList != null) { if (!foundNetDeviceList.IsDeviceExist(ndi)) { foundNetDeviceList.AddNetDevice(ndi); } } } }
public void AddNetDevice(NetDeviceInfo device) { netDeviceInfoList.Add(device); }