Get network equals func working & plug it into networkbuilder

This commit is contained in:
Tim Young 2018-03-17 09:38:15 -05:00
parent b4db7cf99c
commit e1060523ab
2 changed files with 53 additions and 1 deletions

View File

@ -179,6 +179,57 @@ namespace EduNetworkBuilder
}
}
public bool Equals(Network CompareTo)
{
if (PuzzleName != CompareTo.PuzzleName) return false;
if (myHeight != CompareTo.myHeight) return false;
if (myWidth != CompareTo.myWidth) return false;
if (Level != CompareTo.Level) return false;
if (SortOrder != CompareTo.SortOrder) return false;
if (OptionShowLabels != CompareTo.OptionShowLabels) return false;
if (ShowLabelsHere != CompareTo.ShowLabelsHere) return false;
if (VLANsEnabled != CompareTo.VLANsEnabled) return false;
if (VLANPacketColors != CompareTo.VLANPacketColors) return false;
if (_LoadedFromResource != CompareTo._LoadedFromResource) return false;
if (!NetMessage.Equals(CompareTo.NetMessage)) return false;
if (!NetTitle.Equals(CompareTo.NetTitle)) return false;
if (!NetURL.Equals(CompareTo.NetURL)) return false;
if (itemsize != CompareTo.itemsize) return false;
if (UniqueIdentifier != CompareTo.UniqueIdentifier) return false;
if (IsRandomNetwork != CompareTo.IsRandomNetwork) return false;
if (NetworkFilename != CompareTo.NetworkFilename) return false;
if (AlreadyDisplayedMessage != CompareTo.AlreadyDisplayedMessage) return false;
if (HintsToDisplay != CompareTo.HintsToDisplay) return false;
if (StartingHelpLevel != CompareTo.StartingHelpLevel) return false;
if (PuzzleIsSolved != CompareTo.PuzzleIsSolved) return false;
if (NetTests.Count != CompareTo.NetTests.Count) return false;
for (int i = 0; i < NetTests.Count; i++)
if (!NetTests[i].Equals(CompareTo.NetTests[i])) return false;
if (BrokenItems.Count != CompareTo.BrokenItems.Count) return false;
for (int i = 0; i < BrokenItems.Count; i++)
if (BrokenItems[i] != CompareTo.BrokenItems[i]) return false;
if (NetComponents.Count != CompareTo.NetComponents.Count) return false;
for (int i = 0; i < NetComponents.Count; i++)
if (!NetComponents[i].Equals(CompareTo.NetComponents[i])) return false;
if (Shapes.Count != CompareTo.Shapes.Count) return false;
for (int i = 0; i < Shapes.Count; i++)
if (!Shapes[i].Equals(CompareTo.Shapes[i])) return false;
if (PingTestStats.Count != CompareTo.PingTestStats.Count) return false;
if (SuggestedReadings.Count != CompareTo.SuggestedReadings.Count) return false;
if (myMessages.Count != CompareTo.myMessages.Count) return false;
if (VlanNames.Count != CompareTo.VlanNames.Count) return false;
for (int i = 0; i < VlanNames.Count; i++)
if (!VlanNames[i].Equals(CompareTo.VlanNames[i])) return false;
return true;
}
public void ClearComponents()
{
NetComponents.Clear();

View File

@ -243,7 +243,8 @@ namespace EduNetworkBuilder
public void StoreNetworkState(Network toStore)
{
//We should verify something has changed before storing it. Oh well...
if (storedNetworkStates.Count > 0 && toStore.Equals(storedNetworkStates[0]))
return; //The states are identical. Do not store this state.
storedNetworkStates.Insert(0,Network.DeepClone(toStore));
int maxCount = 30;
if(storedNetworkStates.Count > maxCount)