mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Perform mass cleanup
This is cleanup based on both new .NET functionality (in 6 and 7) as well as a ton of simplifications and things that were missed that were caught due to the cleanup.
This commit is contained in:
@@ -162,7 +162,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
reader.MoveToContent();
|
||||
|
||||
// Create the Rom to store the info
|
||||
Rom rom = new Rom
|
||||
Rom rom = new()
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
ArchiveDotOrgSource = reader.GetAttribute("source"),
|
||||
@@ -187,7 +187,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
rom.Machine.Name = splitpath[0];
|
||||
rom.Machine.Description = splitpath[0];
|
||||
|
||||
rom.Name = rom.Name.Substring(splitpath[0].Length + 1);
|
||||
rom.Name = rom.Name[(splitpath[0].Length + 1)..];
|
||||
}
|
||||
|
||||
// TODO: Handle SuperDAT
|
||||
@@ -287,7 +287,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
XmlTextWriter xtw = new XmlTextWriter(fs, new UTF8Encoding(false))
|
||||
XmlTextWriter xtw = new(fs, new UTF8Encoding(false))
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
IndentChar = ' ',
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Open a file reader
|
||||
Encoding enc = filename.GetEncoding();
|
||||
SeparatedValueReader svr = new SeparatedValueReader(System.IO.File.OpenRead(filename), enc)
|
||||
SeparatedValueReader svr = new(System.IO.File.OpenRead(filename), enc)
|
||||
{
|
||||
Header = true,
|
||||
Quotes = false,
|
||||
@@ -56,7 +56,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Get the current line, split and parse
|
||||
svr.ReadNextLine();
|
||||
|
||||
Rom rom = new Rom
|
||||
Rom rom = new()
|
||||
{
|
||||
Name = "-",
|
||||
Size = Constants.SizeZero,
|
||||
@@ -134,7 +134,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
SeparatedValueWriter svw = new SeparatedValueWriter(fs, new UTF8Encoding(false))
|
||||
SeparatedValueWriter svw = new(fs, new UTF8Encoding(false))
|
||||
{
|
||||
Quotes = false,
|
||||
Separator = ';',
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Open a file reader
|
||||
Encoding enc = filename.GetEncoding();
|
||||
ClrMameProReader cmpr = new ClrMameProReader(System.IO.File.OpenRead(filename), enc)
|
||||
ClrMameProReader cmpr = new(System.IO.File.OpenRead(filename), enc)
|
||||
{
|
||||
DosCenter = false,
|
||||
Quotes = Quotes,
|
||||
@@ -210,7 +210,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Prepare all internal variables
|
||||
bool containsItems = false;
|
||||
Machine machine = new Machine()
|
||||
Machine machine = new()
|
||||
{
|
||||
MachineType = (resource ? MachineType.Bios : MachineType.NULL),
|
||||
};
|
||||
@@ -402,7 +402,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// If no items were found for this machine, add a Blank placeholder
|
||||
if (!containsItems)
|
||||
{
|
||||
Blank blank = new Blank()
|
||||
Blank blank = new()
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
@@ -455,7 +455,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
ClrMameProWriter cmpw = new ClrMameProWriter(fs, new UTF8Encoding(false))
|
||||
ClrMameProWriter cmpw = new(fs, new UTF8Encoding(false))
|
||||
{
|
||||
Quotes = Quotes
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Open a file reader
|
||||
Encoding enc = filename.GetEncoding();
|
||||
ClrMameProReader cmpr = new ClrMameProReader(System.IO.File.OpenRead(filename), enc)
|
||||
ClrMameProReader cmpr = new(System.IO.File.OpenRead(filename), enc)
|
||||
{
|
||||
DosCenter = true
|
||||
};
|
||||
@@ -143,7 +143,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Prepare all internal variables
|
||||
bool containsItems = false;
|
||||
Machine machine = new Machine()
|
||||
Machine machine = new()
|
||||
{
|
||||
MachineType = MachineType.NULL,
|
||||
};
|
||||
@@ -236,7 +236,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// If no items were found for this machine, add a Blank placeholder
|
||||
if (!containsItems)
|
||||
{
|
||||
Blank blank = new Blank()
|
||||
Blank blank = new()
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
@@ -280,7 +280,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
ClrMameProWriter cmpw = new ClrMameProWriter(fs, new UTF8Encoding(false))
|
||||
ClrMameProWriter cmpw = new(fs, new UTF8Encoding(false))
|
||||
{
|
||||
Quotes = false
|
||||
};
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Open a file reader
|
||||
Encoding enc = filename.GetEncoding();
|
||||
SeparatedValueReader svr = new SeparatedValueReader(System.IO.File.OpenRead(filename), enc)
|
||||
SeparatedValueReader svr = new(System.IO.File.OpenRead(filename), enc)
|
||||
{
|
||||
Header = false,
|
||||
Quotes = false,
|
||||
@@ -63,7 +63,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
string[] fullname = svr.Line[1].Split('/');
|
||||
|
||||
Rom rom = new Rom
|
||||
Rom rom = new()
|
||||
{
|
||||
Name = svr.Line[1][(fullname[0].Length + 1)..],
|
||||
Size = null, // No size provided, but we don't want the size being 0
|
||||
@@ -131,7 +131,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
SeparatedValueWriter svw = new SeparatedValueWriter(fs, new UTF8Encoding(false))
|
||||
SeparatedValueWriter svw = new(fs, new UTF8Encoding(false))
|
||||
{
|
||||
Quotes = false,
|
||||
Separator = '\t',
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Open a file reader
|
||||
Encoding enc = filename.GetEncoding();
|
||||
StreamReader sr = new StreamReader(System.IO.File.OpenRead(filename), enc);
|
||||
StreamReader sr = new(System.IO.File.OpenRead(filename), enc);
|
||||
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
@@ -66,16 +66,16 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
split = name.Split('/');
|
||||
machine = split[0];
|
||||
name = name.Substring(machine.Length + 1);
|
||||
name = name[(machine.Length + 1)..];
|
||||
}
|
||||
else if (name.Contains('\\'))
|
||||
{
|
||||
split = name.Split('\\');
|
||||
machine = split[0];
|
||||
name = name.Substring(machine.Length + 1);
|
||||
name = name[(machine.Length + 1)..];
|
||||
}
|
||||
|
||||
Rom rom = new Rom
|
||||
Rom rom = new()
|
||||
{
|
||||
Name = name,
|
||||
Size = null,
|
||||
@@ -122,7 +122,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
List<DatItemField> missingFields = new List<DatItemField>();
|
||||
List<DatItemField> missingFields = new();
|
||||
|
||||
// Check item name
|
||||
if (string.IsNullOrWhiteSpace(datItem.GetName()))
|
||||
@@ -259,7 +259,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
SeparatedValueWriter svw = new SeparatedValueWriter(fs, new UTF8Encoding(false))
|
||||
SeparatedValueWriter svw = new(fs, new UTF8Encoding(false))
|
||||
{
|
||||
Quotes = false,
|
||||
Separator = ' ',
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Open a file reader
|
||||
Encoding enc = filename.GetEncoding();
|
||||
StreamReader sr = new StreamReader(System.IO.File.OpenRead(filename), enc);
|
||||
StreamReader sr = new(System.IO.File.OpenRead(filename), enc);
|
||||
|
||||
string gamename = string.Empty;
|
||||
while (!sr.EndOfStream)
|
||||
@@ -90,12 +90,12 @@ namespace SabreTools.DatFiles.Formats
|
||||
line = line[romname.Length..];
|
||||
|
||||
// Next we separate the ROM into pieces
|
||||
split = line.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
|
||||
split = line.Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
// Standard Disks have 2 pieces (name, sha1)
|
||||
if (split.Length == 1)
|
||||
{
|
||||
Disk disk = new Disk()
|
||||
Disk disk = new()
|
||||
{
|
||||
Name = romname,
|
||||
SHA1 = CleanListromHashData(split[0]),
|
||||
@@ -118,7 +118,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Baddump Disks have 4 pieces (name, BAD, sha1, BAD_DUMP)
|
||||
else if (split.Length == 3 && line.EndsWith("BAD_DUMP"))
|
||||
{
|
||||
Disk disk = new Disk()
|
||||
Disk disk = new()
|
||||
{
|
||||
Name = romname,
|
||||
SHA1 = CleanListromHashData(split[1]),
|
||||
@@ -142,7 +142,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Standard ROMs have 4 pieces (name, size, crc, sha1)
|
||||
else if (split.Length == 3)
|
||||
{
|
||||
Rom rom = new Rom()
|
||||
Rom rom = new()
|
||||
{
|
||||
Name = romname,
|
||||
Size = Utilities.CleanLong(split[0]),
|
||||
@@ -167,7 +167,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Nodump Disks have 5 pieces (name, NO, GOOD, DUMP, KNOWN)
|
||||
else if (split.Length == 4 && line.EndsWith("NO GOOD DUMP KNOWN"))
|
||||
{
|
||||
Disk disk = new Disk()
|
||||
Disk disk = new()
|
||||
{
|
||||
Name = romname,
|
||||
ItemStatus = ItemStatus.Nodump,
|
||||
@@ -190,7 +190,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Baddump ROMs have 6 pieces (name, size, BAD, crc, sha1, BAD_DUMP)
|
||||
else if (split.Length == 5 && line.EndsWith("BAD_DUMP"))
|
||||
{
|
||||
Rom rom = new Rom()
|
||||
Rom rom = new()
|
||||
{
|
||||
Name = romname,
|
||||
Size = Utilities.CleanLong(split[0]),
|
||||
@@ -216,7 +216,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Nodump ROMs have 6 pieces (name, size, NO, GOOD, DUMP, KNOWN)
|
||||
else if (split.Length == 5 && line.EndsWith("NO GOOD DUMP KNOWN"))
|
||||
{
|
||||
Rom rom = new Rom()
|
||||
Rom rom = new()
|
||||
{
|
||||
Name = romname,
|
||||
Size = Utilities.CleanLong(split[0]),
|
||||
@@ -261,7 +261,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
List<DatItemField> missingFields = new List<DatItemField>();
|
||||
List<DatItemField> missingFields = new();
|
||||
|
||||
// Check item name
|
||||
if (string.IsNullOrWhiteSpace(datItem.GetName()))
|
||||
@@ -287,7 +287,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(false));
|
||||
StreamWriter sw = new(fs, new UTF8Encoding(false));
|
||||
|
||||
// Write out each of the machines and roms
|
||||
string lastgame = null;
|
||||
|
||||
@@ -295,7 +295,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
if (reader.GetAttribute("ismechanical").AsYesNo() == true)
|
||||
machineType |= MachineType.Mechanical;
|
||||
|
||||
Machine machine = new Machine
|
||||
Machine machine = new()
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Description = reader.GetAttribute("name"),
|
||||
@@ -309,7 +309,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
};
|
||||
|
||||
// Get list for new DatItems
|
||||
List<DatItem> datItems = new List<DatItem>();
|
||||
List<DatItem> datItems = new();
|
||||
|
||||
while (!reader.EOF)
|
||||
{
|
||||
@@ -776,7 +776,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// If no items were found for this machine, add a Blank placeholder
|
||||
else
|
||||
{
|
||||
Blank blank = new Blank()
|
||||
Blank blank = new()
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
@@ -1370,7 +1370,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
XmlTextWriter xtw = new XmlTextWriter(fs, new UTF8Encoding(false))
|
||||
XmlTextWriter xtw = new(fs, new UTF8Encoding(false))
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
IndentChar = '\t',
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
ValidationType = ValidationType.None,
|
||||
});
|
||||
|
||||
List<string> dirs = new List<string>();
|
||||
List<string> dirs = new();
|
||||
|
||||
// If we got a null reader, just return
|
||||
if (xtr == null)
|
||||
@@ -474,8 +474,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
if (reader.GetAttribute("ismechanical").AsYesNo() == true) // Listxml-specific, used by older DATs
|
||||
machineType |= MachineType.Mechanical;
|
||||
|
||||
string dirsString = (dirs != null && dirs.Count() > 0 ? string.Join("/", dirs) + "/" : string.Empty);
|
||||
Machine machine = new Machine
|
||||
string dirsString = (dirs != null && dirs.Count > 0 ? string.Join("/", dirs) + "/" : string.Empty);
|
||||
Machine machine = new()
|
||||
{
|
||||
Name = dirsString + reader.GetAttribute("name"),
|
||||
Description = dirsString + reader.GetAttribute("name"),
|
||||
@@ -727,7 +727,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// If no items were found for this machine, add a Blank placeholder
|
||||
if (!containsItems)
|
||||
{
|
||||
Blank blank = new Blank()
|
||||
Blank blank = new()
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
@@ -869,7 +869,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
XmlTextWriter xtw = new XmlTextWriter(fs, new UTF8Encoding(false))
|
||||
XmlTextWriter xtw = new(fs, new UTF8Encoding(false))
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
IndentChar = '\t',
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(false));
|
||||
StreamWriter sw = new(fs, new UTF8Encoding(false));
|
||||
|
||||
// Write out each of the machines and roms
|
||||
string lastgame = null;
|
||||
|
||||
@@ -470,8 +470,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Prepare all internal variables
|
||||
string releaseNumber = string.Empty, duplicateid;
|
||||
long? size = null;
|
||||
List<Rom> datItems = new List<Rom>();
|
||||
Machine machine = new Machine();
|
||||
List<Rom> datItems = new();
|
||||
Machine machine = new();
|
||||
|
||||
// If there's no subtree to the configuration, skip it
|
||||
if (reader == null)
|
||||
@@ -683,7 +683,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
XmlTextWriter xtw = new XmlTextWriter(fs, new UTF8Encoding(false))
|
||||
XmlTextWriter xtw = new(fs, new UTF8Encoding(false))
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
IndentChar = '\t',
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
bool containsItems = false;
|
||||
|
||||
// Create a new machine
|
||||
Machine machine = new Machine();
|
||||
Machine machine = new();
|
||||
|
||||
while (!reader.EOF)
|
||||
{
|
||||
@@ -180,7 +180,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// If no items were found for this machine, add a Blank placeholder
|
||||
if (!containsItems)
|
||||
{
|
||||
Blank blank = new Blank()
|
||||
Blank blank = new()
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
@@ -215,7 +215,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
string filename,
|
||||
int indexId)
|
||||
{
|
||||
List<DatItem> items = new List<DatItem>();
|
||||
List<DatItem> items = new();
|
||||
Original original = null;
|
||||
|
||||
while (!reader.EOF)
|
||||
@@ -556,7 +556,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
XmlTextWriter xtw = new XmlTextWriter(fs, new UTF8Encoding(false))
|
||||
XmlTextWriter xtw = new(fs, new UTF8Encoding(false))
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
IndentChar = '\t',
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
public override void ParseFile(string filename, int indexId, bool keep, bool statsOnly = false, bool throwOnError = false)
|
||||
{
|
||||
// Prepare all intenral variables
|
||||
IniReader ir = new IniReader(filename) { ValidateRows = false };
|
||||
IniReader ir = new(filename) { ValidateRows = false };
|
||||
|
||||
// If we got a null reader, just return
|
||||
if (ir == null)
|
||||
@@ -326,7 +326,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
9 - merge name
|
||||
*/
|
||||
string[] rominfo = line.Split('¬');
|
||||
Rom rom = new Rom
|
||||
Rom rom = new()
|
||||
{
|
||||
Name = rominfo[5],
|
||||
Size = Utilities.CleanLong(rominfo[7]),
|
||||
@@ -385,14 +385,14 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
IniWriter iw = new IniWriter(fs, new UTF8Encoding(false));
|
||||
IniWriter iw = new(fs, new UTF8Encoding(false));
|
||||
|
||||
// Write out the header
|
||||
WriteHeader(iw);
|
||||
|
||||
// Write out each of the machines and roms
|
||||
string lastgame = null;
|
||||
List<string> splitpath = new List<string>();
|
||||
List<string> splitpath = new();
|
||||
|
||||
// Use a sorted list of games to output
|
||||
foreach (string key in Items.SortedKeys)
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
public override void ParseFile(string filename, int indexId, bool keep, bool statsOnly = false, bool throwOnError = false)
|
||||
{
|
||||
// Prepare all internal variables
|
||||
StreamReader sr = new StreamReader(System.IO.File.OpenRead(filename), new UTF8Encoding(false));
|
||||
JsonTextReader jtr = new JsonTextReader(sr);
|
||||
StreamReader sr = new(System.IO.File.OpenRead(filename), new UTF8Encoding(false));
|
||||
JsonTextReader jtr = new(sr);
|
||||
|
||||
// If we got a null reader, just return
|
||||
if (jtr == null)
|
||||
@@ -91,7 +91,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Read in the header and apply any new fields
|
||||
jtr.Read();
|
||||
JsonSerializer js = new JsonSerializer();
|
||||
JsonSerializer js = new();
|
||||
DatHeader header = js.Deserialize<DatHeader>(jtr);
|
||||
Header.ConditionalCopy(header);
|
||||
}
|
||||
@@ -111,7 +111,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Read in the machine array
|
||||
jtr.Read();
|
||||
JsonSerializer js = new JsonSerializer();
|
||||
JsonSerializer js = new();
|
||||
JArray machineArray = js.Deserialize<JArray>(jtr);
|
||||
|
||||
// Loop through each machine object and process
|
||||
@@ -355,8 +355,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(false));
|
||||
JsonTextWriter jtw = new JsonTextWriter(sw)
|
||||
StreamWriter sw = new(fs, new UTF8Encoding(false));
|
||||
JsonTextWriter jtw = new(sw)
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
IndentChar = '\t',
|
||||
@@ -431,7 +431,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Write the DatHeader
|
||||
jtw.WritePropertyName("header");
|
||||
JsonSerializer js = new JsonSerializer() { Formatting = Formatting.Indented };
|
||||
JsonSerializer js = new() { Formatting = Formatting.Indented };
|
||||
js.Serialize(jtw, Header);
|
||||
|
||||
jtw.WritePropertyName("machines");
|
||||
@@ -455,7 +455,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Write the Machine
|
||||
jtw.WritePropertyName("machine");
|
||||
JsonSerializer js = new JsonSerializer() { Formatting = Formatting.Indented };
|
||||
JsonSerializer js = new() { Formatting = Formatting.Indented };
|
||||
js.Serialize(jtw, datItem.Machine);
|
||||
|
||||
jtw.WritePropertyName("items");
|
||||
@@ -494,7 +494,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Write the DatItem
|
||||
jtw.WritePropertyName("datitem");
|
||||
JsonSerializer js = new JsonSerializer() { ContractResolver = new BaseFirstContractResolver(), Formatting = Formatting.Indented };
|
||||
JsonSerializer js = new() { ContractResolver = new BaseFirstContractResolver(), Formatting = Formatting.Indented };
|
||||
js.Serialize(jtw, datItem);
|
||||
|
||||
// End item
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
switch (xtr.Name)
|
||||
{
|
||||
case "header":
|
||||
XmlSerializer xs = new XmlSerializer(typeof(DatHeader));
|
||||
XmlSerializer xs = new(typeof(DatHeader));
|
||||
DatHeader header = xs.Deserialize(xtr.ReadSubtree()) as DatHeader;
|
||||
Header.ConditionalCopy(header);
|
||||
xtr.Skip();
|
||||
@@ -116,7 +116,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
switch (xtr.Name)
|
||||
{
|
||||
case "machine":
|
||||
XmlSerializer xs = new XmlSerializer(typeof(Machine));
|
||||
XmlSerializer xs = new(typeof(Machine));
|
||||
machine = xs.Deserialize(xtr.ReadSubtree()) as Machine;
|
||||
xtr.Skip();
|
||||
break;
|
||||
@@ -162,7 +162,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
switch (xtr.Name)
|
||||
{
|
||||
case "datitem":
|
||||
XmlSerializer xs = new XmlSerializer(typeof(DatItem));
|
||||
XmlSerializer xs = new(typeof(DatItem));
|
||||
DatItem item = xs.Deserialize(xtr.ReadSubtree()) as DatItem;
|
||||
item.CopyMachineInformation(machine);
|
||||
item.Source = new Source { Name = filename, Index = indexId };
|
||||
@@ -191,7 +191,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
XmlTextWriter xtw = new XmlTextWriter(fs, new UTF8Encoding(false))
|
||||
XmlTextWriter xtw = new(fs, new UTF8Encoding(false))
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
IndentChar = '\t',
|
||||
@@ -266,8 +266,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
xtw.WriteStartElement("datafile");
|
||||
|
||||
XmlSerializer xs = new XmlSerializer(typeof(DatHeader));
|
||||
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
|
||||
XmlSerializer xs = new(typeof(DatHeader));
|
||||
XmlSerializerNamespaces ns = new();
|
||||
ns.Add("", "");
|
||||
xs.Serialize(xtw, Header, ns);
|
||||
|
||||
@@ -288,8 +288,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Write the machine
|
||||
xtw.WriteStartElement("directory");
|
||||
XmlSerializer xs = new XmlSerializer(typeof(Machine));
|
||||
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
|
||||
XmlSerializer xs = new(typeof(Machine));
|
||||
XmlSerializerNamespaces ns = new();
|
||||
ns.Add("", "");
|
||||
xs.Serialize(xtw, datItem.Machine, ns);
|
||||
|
||||
@@ -324,8 +324,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
ProcessItemName(datItem, true);
|
||||
|
||||
// Write the DatItem
|
||||
XmlSerializer xs = new XmlSerializer(typeof(DatItem));
|
||||
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
|
||||
XmlSerializer xs = new(typeof(DatItem));
|
||||
XmlSerializerNamespaces ns = new();
|
||||
ns.Add("", "");
|
||||
xs.Serialize(xtw, datItem, ns);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
// Open a file reader
|
||||
Encoding enc = filename.GetEncoding();
|
||||
SeparatedValueReader svr = new SeparatedValueReader(System.IO.File.OpenRead(filename), enc)
|
||||
SeparatedValueReader svr = new(System.IO.File.OpenRead(filename), enc)
|
||||
{
|
||||
Header = true,
|
||||
Quotes = true,
|
||||
@@ -60,11 +60,11 @@ namespace SabreTools.DatFiles.Formats
|
||||
svr.ReadNextLine();
|
||||
|
||||
// Create mapping dictionaries
|
||||
Setter setter = new Setter();
|
||||
Setter setter = new();
|
||||
setter.PopulateSettersFromList(svr.HeaderValues, svr.Line);
|
||||
|
||||
// Set DatHeader fields
|
||||
DatHeader datHeader = new DatHeader();
|
||||
DatHeader datHeader = new();
|
||||
setter.SetFields(datHeader);
|
||||
Header.ConditionalCopy(datHeader);
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
SeparatedValueWriter svw = new SeparatedValueWriter(fs, new UTF8Encoding(false))
|
||||
SeparatedValueWriter svw = new(fs, new UTF8Encoding(false))
|
||||
{
|
||||
Quotes = true,
|
||||
Separator = this._delim,
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
bool containsItems = false;
|
||||
|
||||
// Create a new machine
|
||||
Machine machine = new Machine
|
||||
Machine machine = new()
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
CloneOf = reader.GetAttribute("cloneof"),
|
||||
@@ -262,7 +262,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// If no items were found for this machine, add a Blank placeholder
|
||||
if (!containsItems)
|
||||
{
|
||||
Blank blank = new Blank()
|
||||
Blank blank = new()
|
||||
{
|
||||
Source = new Source
|
||||
{
|
||||
@@ -295,7 +295,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Get lists ready
|
||||
part.Features = new List<PartFeature>();
|
||||
List<DatItem> items = new List<DatItem>();
|
||||
List<DatItem> items = new();
|
||||
|
||||
while (!reader.EOF)
|
||||
{
|
||||
@@ -434,7 +434,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <param name="dataArea">DataArea representing the enclosing area</param>
|
||||
private List<DatItem> ReadDataArea(XmlReader reader, DataArea dataArea)
|
||||
{
|
||||
List<DatItem> items = new List<DatItem>();
|
||||
List<DatItem> items = new();
|
||||
|
||||
while (!reader.EOF)
|
||||
{
|
||||
@@ -483,7 +483,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <param name="diskArea">DiskArea representing the enclosing area</param>
|
||||
private List<DatItem> ReadDiskArea(XmlReader reader, DiskArea diskArea)
|
||||
{
|
||||
List<DatItem> items = new List<DatItem>();
|
||||
List<DatItem> items = new();
|
||||
|
||||
while (!reader.EOF)
|
||||
{
|
||||
@@ -586,7 +586,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <inheritdoc/>
|
||||
protected override List<DatItemField> GetMissingRequiredFields(DatItem datItem)
|
||||
{
|
||||
List<DatItemField> missingFields = new List<DatItemField>();
|
||||
List<DatItemField> missingFields = new();
|
||||
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
@@ -705,7 +705,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
return false;
|
||||
}
|
||||
|
||||
XmlTextWriter xtw = new XmlTextWriter(fs, new UTF8Encoding(false))
|
||||
XmlTextWriter xtw = new(fs, new UTF8Encoding(false))
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
IndentChar = '\t',
|
||||
|
||||
Reference in New Issue
Block a user