[DatFile, DatItem] Fix desc-to-name replacements

Previously, sets that had multiple items would trigger issues because of shared information in the items, mostly the Machine parts. By making all of it a clone, it takes a little more memory but ends up resolving all issues in desc-to-name mapping and replacement.
This commit is contained in:
Matt Nadareski
2017-05-14 23:53:03 -07:00
parent bad61d1ed1
commit c65dd866d6
8 changed files with 70 additions and 49 deletions

View File

@@ -14,7 +14,7 @@ using NaturalSort;
namespace SabreTools.Library.Dats
{
public abstract class DatItem : IEquatable<DatItem>, IComparable<DatItem>
public abstract class DatItem : IEquatable<DatItem>, IComparable<DatItem>, ICloneable
{
#region Protected instance variables
@@ -144,6 +144,31 @@ namespace SabreTools.Library.Dats
#region Instance Methods
#region Cloning Methods
public object Clone()
{
switch (_itemType)
{
case ItemType.Archive:
return ((Archive)this).Clone();
case ItemType.BiosSet:
return ((BiosSet)this).Clone();
case ItemType.Disk:
return ((Disk)this).Clone();
case ItemType.Release:
return ((Release)this).Clone();
case ItemType.Rom:
return ((Rom)this).Clone();
case ItemType.Sample:
return ((Sample)this).Clone();
}
return null;
}
#endregion
#region Comparision Methods
public int CompareTo(DatItem other)