From 78340b681377c8f4bb0fb8bccdb0cd4865fcc68b Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 14 Jun 2020 23:07:31 -0700 Subject: [PATCH] KVP >> Tuple --- SabreTools.Library/DatFiles/Listxml.cs | 6 ++--- SabreTools.Library/DatFiles/OfflineList.cs | 12 ++++----- SabreTools.Library/DatFiles/SeparatedValue.cs | 10 +++---- SabreTools.Library/DatFiles/SoftwareList.cs | 26 +++++++++---------- SabreTools.Library/DatItems/DatItem.cs | 12 ++++----- SabreTools.Library/DatItems/Machine.cs | 2 +- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/SabreTools.Library/DatFiles/Listxml.cs b/SabreTools.Library/DatFiles/Listxml.cs index 8281c544..9b318bd5 100644 --- a/SabreTools.Library/DatFiles/Listxml.cs +++ b/SabreTools.Library/DatFiles/Listxml.cs @@ -734,11 +734,11 @@ namespace SabreTools.Library.DatFiles if (!ExcludeFields[(int)Field.Infos] && datItem.Infos != null && datItem.Infos.Count > 0) { - foreach (Tuple kvp in datItem.Infos) + foreach (KeyValuePair kvp in datItem.Infos) { xtw.WriteStartElement("info"); - xtw.WriteAttributeString("name", kvp.Item1); - xtw.WriteAttributeString("value", kvp.Item2); + xtw.WriteAttributeString("name", kvp.Key); + xtw.WriteAttributeString("value", kvp.Value); xtw.WriteEndElement(); } } diff --git a/SabreTools.Library/DatFiles/OfflineList.cs b/SabreTools.Library/DatFiles/OfflineList.cs index b5151a90..e445fa20 100644 --- a/SabreTools.Library/DatFiles/OfflineList.cs +++ b/SabreTools.Library/DatFiles/OfflineList.cs @@ -699,8 +699,8 @@ namespace SabreTools.Library.DatFiles bool remUnicode) { // Prepare all internal variables - List> extensionToCrc = new List>(); - List roms = new List(); + var extensionToCrc = new List>(); + var roms = new List(); // If there's no subtree to the configuration, skip it if (reader == null) @@ -724,7 +724,7 @@ namespace SabreTools.Library.DatFiles { case "romcrc": extensionToCrc.Add( - new Tuple( + new KeyValuePair( reader.GetAttribute("extension") ?? string.Empty, reader.ReadElementContentAsString().ToLowerInvariant())); break; @@ -736,12 +736,12 @@ namespace SabreTools.Library.DatFiles } // Now process the roms with the proper information - foreach (Tuple pair in extensionToCrc) + foreach (KeyValuePair pair in extensionToCrc) { roms.Add(new Rom() { - Name = (releaseNumber != "0" ? releaseNumber + " - " : string.Empty) + machineName + pair.Item1, - CRC = Utilities.CleanHashData(pair.Item2, Constants.CRCLength), + Name = (releaseNumber != "0" ? releaseNumber + " - " : string.Empty) + machineName + pair.Key, + CRC = Utilities.CleanHashData(pair.Value, Constants.CRCLength), ItemStatus = ItemStatus.None, }); diff --git a/SabreTools.Library/DatFiles/SeparatedValue.cs b/SabreTools.Library/DatFiles/SeparatedValue.cs index 8a534c8b..0b2a4a4e 100644 --- a/SabreTools.Library/DatFiles/SeparatedValue.cs +++ b/SabreTools.Library/DatFiles/SeparatedValue.cs @@ -109,7 +109,7 @@ namespace SabreTools.Library.DatFiles long size = -1; ItemType itemType = ItemType.Rom; ItemStatus status = ItemStatus.None; - List> features = null; + List> features = null; // Now we loop through and get values for everything for (int i = 0; i < svr.HeaderValues.Count; i++) @@ -293,12 +293,12 @@ namespace SabreTools.Library.DatFiles break; case "Machine.Infos": - machine.Infos = new List>(); + machine.Infos = new List>(); var infos = value.Split(';'); foreach (var info in infos) { var infoPair = info.Split('='); - machine.Infos.Add(new Tuple(infoPair[0], infoPair[1])); + machine.Infos.Add(new KeyValuePair(infoPair[0], infoPair[1])); } break; @@ -328,12 +328,12 @@ namespace SabreTools.Library.DatFiles break; case "DatItem.Features": - features = new List>(); + features = new List>(); var splitFeatures = value.Split(';'); foreach (var splitFeature in splitFeatures) { var featurePair = splitFeature.Split('='); - features.Add(new Tuple(featurePair[0], featurePair[1])); + features.Add(new KeyValuePair(featurePair[0], featurePair[1])); } break; diff --git a/SabreTools.Library/DatFiles/SoftwareList.cs b/SabreTools.Library/DatFiles/SoftwareList.cs index a310ed35..1a9e2f14 100644 --- a/SabreTools.Library/DatFiles/SoftwareList.cs +++ b/SabreTools.Library/DatFiles/SoftwareList.cs @@ -161,7 +161,7 @@ namespace SabreTools.Library.DatFiles Supported = Utilities.GetYesNo(reader.GetAttribute("supported")), // (yes|partial|no) "yes" CloneOf = reader.GetAttribute("cloneof") ?? string.Empty, - Infos = new List>(), + Infos = new List>(), MachineType = (machineType == MachineType.NULL ? MachineType.None : machineType), }; @@ -191,7 +191,7 @@ namespace SabreTools.Library.DatFiles break; case "info": - machine.Infos.Add(new Tuple(reader.GetAttribute("name"), reader.GetAttribute("value"))); + machine.Infos.Add(new KeyValuePair(reader.GetAttribute("name"), reader.GetAttribute("value"))); reader.Read(); break; @@ -258,7 +258,7 @@ namespace SabreTools.Library.DatFiles string key = string.Empty, areaname = string.Empty, partname = string.Empty, partinterface = string.Empty; string temptype = reader.Name; long? areasize = null; - List> features = new List>(); + var features = new List>(); bool containsItems = false; while (!reader.EOF) @@ -270,7 +270,7 @@ namespace SabreTools.Library.DatFiles { partname = string.Empty; partinterface = string.Empty; - features = new List>(); + features = new List>(); } if (reader.NodeType == XmlNodeType.EndElement && (reader.Name == "dataarea" || reader.Name == "diskarea")) @@ -293,7 +293,7 @@ namespace SabreTools.Library.DatFiles break; case "feature": - features.Add(new Tuple(reader.GetAttribute("name"), reader.GetAttribute("feature"))); + features.Add(new KeyValuePair(reader.GetAttribute("name"), reader.GetAttribute("feature"))); reader.Read(); break; @@ -366,7 +366,7 @@ namespace SabreTools.Library.DatFiles private bool ReadDataArea( XmlReader reader, Machine machine, - List> features, + List> features, string areaname, long? areasize, string partname, @@ -479,7 +479,7 @@ namespace SabreTools.Library.DatFiles private bool ReadDiskArea( XmlReader reader, Machine machine, - List> features, + List> features, string areaname, long? areasize, string partname, @@ -755,11 +755,11 @@ namespace SabreTools.Library.DatFiles if (!ExcludeFields[(int)Field.Infos] && datItem.Infos != null && datItem.Infos.Count > 0) { - foreach (Tuple kvp in datItem.Infos) + foreach (KeyValuePair kvp in datItem.Infos) { xtw.WriteStartElement("info"); - xtw.WriteAttributeString("name", kvp.Item1); - xtw.WriteAttributeString("value", kvp.Item2); + xtw.WriteAttributeString("name", kvp.Key); + xtw.WriteAttributeString("value", kvp.Value); xtw.WriteEndElement(); } } @@ -823,11 +823,11 @@ namespace SabreTools.Library.DatFiles if (!ExcludeFields[(int)Field.Features] && datItem.Features != null && datItem.Features.Count > 0) { - foreach (Tuple kvp in datItem.Features) + foreach (KeyValuePair kvp in datItem.Features) { xtw.WriteStartElement("feature"); - xtw.WriteAttributeString("name", kvp.Item1); - xtw.WriteAttributeString("value", kvp.Item2); + xtw.WriteAttributeString("name", kvp.Key); + xtw.WriteAttributeString("value", kvp.Value); xtw.WriteEndElement(); } } diff --git a/SabreTools.Library/DatItems/DatItem.cs b/SabreTools.Library/DatItems/DatItem.cs index 3075e698..363deae6 100644 --- a/SabreTools.Library/DatItems/DatItem.cs +++ b/SabreTools.Library/DatItems/DatItem.cs @@ -450,7 +450,7 @@ namespace SabreTools.Library.DatItems /// /// List of info items /// - public List> Infos + public List> Infos { get { @@ -514,7 +514,7 @@ namespace SabreTools.Library.DatItems /// /// Features provided to/by the item /// - public List> Features { get; set; } + public List> Features { get; set; } /// /// Original hardware part name within an item @@ -585,7 +585,7 @@ namespace SabreTools.Library.DatItems fieldValue = this.PartInterface; break; case Field.Features: - fieldValue = string.Join(", ", (this.Features ?? new List>()).Select(f => $"{f.Item1}={f.Item2}")); + fieldValue = string.Join(";", (this.Features ?? new List>()).Select(f => $"{f.Key}={f.Value}")); break; case Field.AreaName: fieldValue = this.AreaName; @@ -637,13 +637,13 @@ namespace SabreTools.Library.DatItems fieldValue = this.RebuildTo; break; case Field.Devices: - fieldValue = string.Join(", ", this.Devices ?? new List()); + fieldValue = string.Join(";", this.Devices ?? new List()); break; case Field.SlotOptions: - fieldValue = string.Join(", ", this.SlotOptions ?? new List()); + fieldValue = string.Join(";", this.SlotOptions ?? new List()); break; case Field.Infos: - fieldValue = string.Join(", ", (this.Infos ?? new List>()).Select(i => $"{i.Item1}={i.Item2}")); + fieldValue = string.Join(";", (this.Infos ?? new List>()).Select(i => $"{i.Key}={i.Value}")); break; case Field.MachineType: fieldValue = this.MachineType.ToString(); diff --git a/SabreTools.Library/DatItems/Machine.cs b/SabreTools.Library/DatItems/Machine.cs index 58a3d082..79028323 100644 --- a/SabreTools.Library/DatItems/Machine.cs +++ b/SabreTools.Library/DatItems/Machine.cs @@ -97,7 +97,7 @@ namespace SabreTools.Library.DatItems /// /// List of info items /// - public List> Infos { get; set; } + public List> Infos { get; set; } /// /// Type of the machine