Equals func on network devices

This commit is contained in:
Tim Young 2018-03-16 16:23:41 -05:00
parent ae04d818be
commit 9fd7c6a119

View File

@ -274,6 +274,55 @@ namespace EduNetworkBuilder
SetImageFromType(myType);
}
public override bool Equals(NetworkComponent toCompare)
{
if (!(toCompare is NetworkDevice)) return false; //comparing a link to a device
NetworkDevice CompareDevice = (NetworkDevice)toCompare;
if (IsDirty != CompareDevice.IsDirty) return false;
if (UniqueIdentifier != CompareDevice.UniqueIdentifier) return false;
if (hostname != CompareDevice.hostname) return false;
if (isInvisible != CompareDevice.isInvisible) return false;
if (NICs.Count != CompareDevice.NICs.Count) return false;
for (int i = 0; i < NICs.Count; i++)
if (!NICs[i].Equals(CompareDevice.NICs[i])) return false;
if (!DefaultGW.Equals(CompareDevice.DefaultGW)) return false;
if (MyLocation != CompareDevice.MyLocation) return false;
if (Size != CompareDevice.Size) return false;
if (ArpTable.Count != CompareDevice.ArpTable.Count) return false;
for (int i = 0; i < ArpTable.Count; i++)
if (!ArpTable[i].Equals(CompareDevice.ArpTable[i])) return false;
if (myType != CompareDevice.myType) return false;
if (RouteTable.Count != CompareDevice.RouteTable.Count) return false;
for (int i = 0; i < RouteTable.Count; i++)
if (!RouteTable[i].Equals(CompareDevice.RouteTable[i])) return false;
if (DHCPLeases.Count != CompareDevice.DHCPLeases.Count) return false;
for (int i = 0; i < DHCPLeases.Count; i++)
if (!DHCPLeases[i].Equals(CompareDevice.DHCPLeases[i])) return false;
if (IPConnections.Count != CompareDevice.IPConnections.Count) return false;
for (int i = 0; i < IPConnections.Count; i++)
if (!IPConnections[i].Equals(CompareDevice.IPConnections[i])) return false;
if (isDNSServer != CompareDevice.isDNSServer) return false;
if (isDHCPServer != CompareDevice.isDHCPServer) return false;
if (CanServeDHCP != CompareDevice.CanServeDHCP) return false;
if (CanUseDHCP != CompareDevice.CanUseDHCP) return false;
if (MustUseDHCP != CompareDevice.MustUseDHCP) return false;
if (CanAddNics != CompareDevice.CanAddNics) return false;
if (HasAdvFirewall != CompareDevice.HasAdvFirewall) return false;
if (IsBurned != CompareDevice.IsBurned) return false;
if (BackgroundColor != CompareDevice.BackgroundColor) return false;
if (MorphColor != CompareDevice.MorphColor) return false;
if (PowerOff != CompareDevice.PowerOff) return false;
if (FirewallRules.Count != CompareDevice.FirewallRules.Count) return false;
for (int i = 0; i < FirewallRules.Count; i++)
if (!FirewallRules[i].Equals(CompareDevice.FirewallRules[i])) return false;
if (!tracertmessages.SequenceEqual(CompareDevice.tracertmessages)) return false;
return true;
}
public override void Destroy()
{
Network myNet = NB.GetNetwork();