Fix issues found during testing

This commit is contained in:
Matt Nadareski
2023-08-15 01:38:01 -04:00
parent 3d99cf828f
commit ede4487cf0
56 changed files with 203 additions and 116 deletions

View File

@@ -14,10 +14,7 @@ namespace SabreTools.Core
public static DictionaryBase? Clone(this DictionaryBase dictionaryBase)
{
// Create a new object of the same type
var clone = dictionaryBase
.GetType()
.GetConstructor(System.Reflection.BindingFlags.Public, Array.Empty<Type>())?
.Invoke(null) as DictionaryBase;
var clone = Activator.CreateInstance(dictionaryBase.GetType()) as DictionaryBase;
// If construction failed, we can't do anything
if (clone == null)

View File

@@ -81,37 +81,37 @@ namespace SabreTools.Core.Tools
/// <summary>
/// Normalize a CRC32 string and pad to the correct size
/// </summary>
public static string NormalizeCRC32(string? hash)
public static string? NormalizeCRC32(string? hash)
=> NormalizeHashData(hash, Constants.CRCLength);
/// <summary>
/// Normalize a MD5 string and pad to the correct size
/// </summary>
public static string NormalizeMD5(string? hash)
public static string? NormalizeMD5(string? hash)
=> NormalizeHashData(hash, Constants.MD5Length);
/// <summary>
/// Normalize a SHA1 string and pad to the correct size
/// </summary>
public static string NormalizeSHA1(string? hash)
public static string? NormalizeSHA1(string? hash)
=> NormalizeHashData(hash, Constants.SHA1Length);
/// <summary>
/// Normalize a SHA256 string and pad to the correct size
/// </summary>
public static string NormalizeSHA256(string? hash)
public static string? NormalizeSHA256(string? hash)
=> NormalizeHashData(hash, Constants.SHA256Length);
/// <summary>
/// Normalize a SHA384 string and pad to the correct size
/// </summary>
public static string NormalizeSHA384(string? hash)
public static string? NormalizeSHA384(string? hash)
=> NormalizeHashData(hash, Constants.SHA384Length);
/// <summary>
/// Normalize a SHA512 string and pad to the correct size
/// </summary>
public static string NormalizeSHA512(string? hash)
public static string? NormalizeSHA512(string? hash)
=> NormalizeHashData(hash, Constants.SHA512Length);
/// <summary>
@@ -186,10 +186,12 @@ namespace SabreTools.Core.Tools
/// <summary>
/// Normalize a hash string and pad to the correct size
/// </summary>
private static string NormalizeHashData(string? hash, int expectedLength)
private static string? NormalizeHashData(string? hash, int expectedLength)
{
// If we have a known blank hash, return blank
if (string.IsNullOrWhiteSpace(hash) || hash == "-" || hash == "_")
if (string.IsNullOrWhiteSpace(hash))
return null;
else if (hash == "-" || hash == "_")
return string.Empty;
// Check to see if it's a "hex" hash

View File

@@ -316,7 +316,7 @@ namespace SabreTools.DatFiles
{
// Initialize strings
string fix,
game = item.Machine?.Name ?? string.Empty,
game = item.Machine.Name ?? string.Empty,
name = item.GetName() ?? item.ItemType.ToString(),
crc = string.Empty,
md5 = string.Empty,
@@ -365,9 +365,9 @@ namespace SabreTools.DatFiles
.Replace("%game%", game)
.Replace("%machine%", game)
.Replace("%name%", name)
.Replace("%manufacturer%", item.Machine?.Manufacturer ?? string.Empty)
.Replace("%publisher%", item.Machine?.Publisher ?? string.Empty)
.Replace("%category%", item.Machine?.Category ?? string.Empty)
.Replace("%manufacturer%", item.Machine.Manufacturer ?? string.Empty)
.Replace("%publisher%", item.Machine.Publisher ?? string.Empty)
.Replace("%category%", item.Machine.Category ?? string.Empty)
.Replace("%crc%", crc)
.Replace("%md5%", md5)
.Replace("%sha1%", sha1)
@@ -397,7 +397,7 @@ namespace SabreTools.DatFiles
Header.UseRomName = true;
// Get the name to update
string? name = (Header.UseRomName ? item.GetName() : item.Machine?.Name) ?? string.Empty;
string? name = (Header.UseRomName ? item.GetName() : item.Machine.Name) ?? string.Empty;
// Create the proper Prefix and Postfix
string pre = CreatePrefixPostfix(item, true);
@@ -454,7 +454,7 @@ namespace SabreTools.DatFiles
name += Header.AddExtension;
if (Header.UseRomName && Header.GameName)
name = Path.Combine(item.Machine?.Name ?? string.Empty, name);
name = Path.Combine(item.Machine.Name ?? string.Empty, name);
// Now assign back the formatted name
name = $"{pre}{name}{post}";
@@ -489,7 +489,7 @@ namespace SabreTools.DatFiles
// If the Rom has "null" characteristics, ensure all fields
if (rom.Size == null && rom.CRC == "null")
{
logger.Verbose($"Empty folder found: {datItem.Machine?.Name}");
logger.Verbose($"Empty folder found: {datItem.Machine.Name}");
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
rom.Size = Constants.SizeZero;

View File

@@ -121,23 +121,23 @@ namespace SabreTools.DatFiles.Formats
{
var row = new Models.AttractMode.Row
{
Name = rom.Machine?.Name,
Title = rom.Machine?.Description,
Name = rom.Machine.Name,
Title = rom.Machine.Description,
Emulator = Header.FileName,
CloneOf = rom.Machine?.CloneOf,
Year = rom.Machine?.Year,
Manufacturer = rom.Machine?.Manufacturer,
Category = rom.Machine?.Category,
Players = rom.Machine?.Players,
Rotation = rom.Machine?.Rotation,
Control = rom.Machine?.Control,
Status = rom.Machine?.Status,
DisplayCount = rom.Machine?.DisplayCount,
DisplayType = rom.Machine?.DisplayType,
CloneOf = rom.Machine.CloneOf,
Year = rom.Machine.Year,
Manufacturer = rom.Machine.Manufacturer,
Category = rom.Machine.Category,
Players = rom.Machine.Players,
Rotation = rom.Machine.Rotation,
Control = rom.Machine.Control,
Status = rom.Machine.Status,
DisplayCount = rom.Machine.DisplayCount,
DisplayType = rom.Machine.DisplayType,
AltRomname = rom.AltName,
AltTitle = rom.AltTitle,
Extra = rom.Machine?.Comment,
Buttons = rom.Machine?.Buttons,
Extra = rom.Machine.Comment,
Buttons = rom.Machine.Buttons,
// TODO: Add extended fields
};
return row;

View File

@@ -139,7 +139,7 @@ namespace SabreTools.DatFiles.Formats
var row = new Models.EverdriveSMDB.Row
{
SHA256 = rom.SHA256,
Name = $"{rom.Machine?.Name ?? string.Empty}/{rom.Name}",
Name = $"{rom.Machine.Name ?? string.Empty}/{rom.Name}",
SHA1 = rom.SHA1,
MD5 = rom.MD5,
CRC32 = rom.CRC,

View File

@@ -63,7 +63,7 @@ namespace SabreTools.DatFiles.Formats
WriteDatItem(sw, datItem, lastgame);
// Set the new data to compare against
lastgame = datItem.Machine?.Name;
lastgame = datItem.Machine.Name;
}
}
@@ -94,8 +94,8 @@ namespace SabreTools.DatFiles.Formats
// Romba mode automatically uses item name
if (Header.OutputDepot?.IsActive == true || Header.UseRomName)
sw.Write($"{datItem.GetName() ?? string.Empty}\n");
else if (!Header.UseRomName && datItem.Machine?.Name != lastgame)
sw.Write($"{datItem.Machine?.Name ?? string.Empty}\n");
else if (!Header.UseRomName && datItem.Machine.Name != lastgame)
sw.Write($"{datItem.Machine.Name ?? string.Empty}\n");
sw.Flush();
}

View File

@@ -183,14 +183,14 @@ namespace SabreTools.DatFiles.Formats
{
var rom = new Models.RomCenter.Rom
{
ParentName = item.Machine?.CloneOf,
//ParentDescription = item.Machine?.CloneOfDescription, // TODO: Add to internal model or find mapping
GameName = item.Machine?.Name,
GameDescription = item.Machine?.Description,
ParentName = item.Machine.CloneOf,
//ParentDescription = item.Machine.CloneOfDescription, // TODO: Add to internal model or find mapping
GameName = item.Machine.Name,
GameDescription = item.Machine.Description,
RomName = item.Name,
RomCRC = item.CRC,
RomSize = item.Size?.ToString(),
RomOf = item.Machine?.RomOf,
RomOf = item.Machine.RomOf,
MergeName = item.MergeTag,
};
return rom;

View File

@@ -395,11 +395,11 @@ namespace SabreTools.DatFiles.Formats
DatItem datItem = datItems[index];
// If we have a different game and we're not at the start of the list, output the end of last item
if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant())
if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant())
WriteEndGame(jtw);
// If we have a new game, output the beginning of the new item
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant())
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant())
WriteStartGame(jtw, datItem);
// Check for a "null" item
@@ -410,7 +410,7 @@ namespace SabreTools.DatFiles.Formats
WriteDatItem(jtw, datItem);
// Set the new data to compare against
lastgame = datItem.Machine?.Name;
lastgame = datItem.Machine.Name;
}
}
@@ -457,7 +457,7 @@ namespace SabreTools.DatFiles.Formats
private void WriteStartGame(JsonTextWriter jtw, DatItem datItem)
{
// No game should start with a path separator
if (!string.IsNullOrWhiteSpace(datItem.Machine?.Name))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Name))
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar) ?? string.Empty;
// Build the state

View File

@@ -223,11 +223,11 @@ namespace SabreTools.DatFiles.Formats
DatItem datItem = datItems[index];
// If we have a different game and we're not at the start of the list, output the end of last item
if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant())
if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant())
WriteEndGame(xtw);
// If we have a new game, output the beginning of the new item
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant())
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant())
WriteStartGame(xtw, datItem);
// Check for a "null" item
@@ -238,7 +238,7 @@ namespace SabreTools.DatFiles.Formats
WriteDatItem(xtw, datItem);
// Set the new data to compare against
lastgame = datItem.Machine?.Name;
lastgame = datItem.Machine.Name;
}
}

View File

@@ -162,8 +162,8 @@ namespace SabreTools.DatFiles.Formats
FileName = Header.FileName,
InternalName = Header.Name,
Description = Header.Description,
GameName = disk.Machine?.Name,
GameDescription = disk.Machine?.Description,
GameName = disk.Machine.Name,
GameDescription = disk.Machine.Description,
Type = disk.ItemType.FromItemType(),
RomName = string.Empty,
DiskName = disk.Name,
@@ -190,8 +190,8 @@ namespace SabreTools.DatFiles.Formats
FileName = Header.FileName,
InternalName = Header.Name,
Description = Header.Description,
GameName = media.Machine?.Name,
GameDescription = media.Machine?.Description,
GameName = media.Machine.Name,
GameDescription = media.Machine.Description,
Type = media.ItemType.FromItemType(),
RomName = string.Empty,
DiskName = media.Name,
@@ -218,8 +218,8 @@ namespace SabreTools.DatFiles.Formats
FileName = Header.FileName,
InternalName = Header.Name,
Description = Header.Description,
GameName = rom.Machine?.Name,
GameDescription = rom.Machine?.Description,
GameName = rom.Machine.Name,
GameDescription = rom.Machine.Description,
Type = rom.ItemType.FromItemType(),
RomName = rom.Name,
DiskName = string.Empty,

View File

@@ -728,7 +728,7 @@ namespace SabreTools.DatFiles
// Filter the list
return fi.Where(i => i != null)
.Where(i => !i.Remove)
.Where(i => i.Machine?.Name != null)
.Where(i => i.Machine.Name != null)
.ToConcurrentList();
}
}

View File

@@ -869,7 +869,7 @@ namespace SabreTools.DatFiles
// Filter the list
return fi.Where(i => i != null)
.Where(i => !i.Remove)
.Where(i => i.Machine?.Name != null)
.Where(i => i.Machine.Name != null)
.ToConcurrentList();
}
}

View File

@@ -102,7 +102,7 @@ namespace SabreTools.DatItems
/// </summary>
/// <remarks>Hack on top of internal model</remarks>
[JsonIgnore, XmlIgnore]
public Machine? Machine
public Machine Machine
{
get => _internal.Read<Machine>("MACHINE") ?? new Machine();
set => _internal["MACHINE"] = value;
@@ -180,6 +180,8 @@ namespace SabreTools.DatItems
public DatItem()
{
_internal = new Models.Internal.Blank();
Machine = new Machine();
logger = new Logger(this);
}
@@ -277,7 +279,9 @@ namespace SabreTools.DatItems
if (item?.Machine == null)
return;
Machine = item.Machine.Clone() as Machine;
var cloned = item.Machine.Clone() as Machine;
if (cloned != null)
Machine = cloned;
}
/// <summary>
@@ -289,7 +293,9 @@ namespace SabreTools.DatItems
if (machine == null)
return;
Machine = machine.Clone() as Machine;
var cloned = machine.Clone() as Machine;
if (cloned != null)
Machine = cloned;
}
#endregion
@@ -343,7 +349,7 @@ namespace SabreTools.DatItems
// If the duplicate is external already or should be, set it
if (lastItem.DupeType.HasFlag(DupeType.External) || lastItem?.Source?.Index != Source?.Index)
{
if (lastItem?.Machine?.Name == Machine?.Name && lastItem?.GetName() == GetName())
if (lastItem?.Machine.Name == Machine?.Name && lastItem?.GetName() == GetName())
output = DupeType.External | DupeType.All;
else
output = DupeType.External | DupeType.Hash;
@@ -352,7 +358,7 @@ namespace SabreTools.DatItems
// Otherwise, it's considered an internal dupe
else
{
if (lastItem?.Machine?.Name == Machine?.Name && lastItem?.GetName() == GetName())
if (lastItem?.Machine.Name == Machine?.Name && lastItem?.GetName() == GetName())
output = DupeType.Internal | DupeType.All;
else
output = DupeType.Internal | DupeType.Hash;
@@ -526,7 +532,7 @@ namespace SabreTools.DatItems
}
// If the current machine is a child of the new machine, use the new machine instead
if (saveditem.Machine?.CloneOf == file.Machine?.Name || saveditem.Machine?.RomOf == file.Machine?.Name)
if (saveditem.Machine.CloneOf == file.Machine.Name || saveditem.Machine.RomOf == file.Machine.Name)
{
saveditem.CopyMachineInformation(file);
saveditem.SetName(file.GetName());
@@ -673,7 +679,7 @@ namespace SabreTools.DatItems
NaturalComparer nc = new();
// If machine names match, more refinement is needed
if (x.Machine?.Name == y.Machine?.Name)
if (x.Machine.Name == y.Machine.Name)
{
// If item types match, more refinement is needed
if (x.ItemType == y.ItemType)
@@ -689,7 +695,7 @@ namespace SabreTools.DatItems
// If item names match, then compare on machine or source, depending on the flag
if (xName == yName)
return (norename ? nc.Compare(x.Machine?.Name, y.Machine?.Name) : (x.Source?.Index - y.Source?.Index) ?? 0);
return (norename ? nc.Compare(x.Machine.Name, y.Machine.Name) : (x.Source?.Index - y.Source?.Index) ?? 0);
// Otherwise, just sort based on item names
return nc.Compare(xName, yName);
@@ -704,7 +710,7 @@ namespace SabreTools.DatItems
}
// Otherwise, just sort based on machine name
return nc.Compare(x.Machine?.Name, y.Machine?.Name);
return nc.Compare(x.Machine.Name, y.Machine.Name);
}
catch
{

View File

@@ -70,6 +70,8 @@ namespace SabreTools.DatItems.Formats
public Adjuster()
{
_internal = new Models.Internal.Adjuster();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.Adjuster;
}
@@ -86,7 +88,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -32,6 +32,8 @@ namespace SabreTools.DatItems.Formats
public Analog()
{
_internal = new Models.Internal.Analog();
Machine = new Machine();
ItemType = ItemType.Analog;
}
@@ -47,7 +49,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -107,6 +107,8 @@ namespace SabreTools.DatItems.Formats
public Archive()
{
_internal = new Models.Internal.Archive();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.Archive;
}
@@ -123,7 +125,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -65,6 +65,8 @@ namespace SabreTools.DatItems.Formats
public BiosSet()
{
_internal = new Models.Internal.BiosSet();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.BiosSet;
}
@@ -81,7 +83,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -32,7 +32,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,
};

View File

@@ -81,6 +81,8 @@ namespace SabreTools.DatItems.Formats
public Chip()
{
_internal = new Models.Internal.Chip();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.Chip;
}
@@ -97,7 +99,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -68,6 +68,8 @@ namespace SabreTools.DatItems.Formats
public Condition()
{
_internal = new Models.Internal.Condition();
Machine = new Machine();
ItemType = ItemType.Condition;
}
@@ -83,7 +85,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -68,6 +68,8 @@ namespace SabreTools.DatItems.Formats
public ConfLocation()
{
_internal = new Models.Internal.ConfLocation();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.ConfLocation;
}
@@ -84,7 +86,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -80,6 +80,8 @@ namespace SabreTools.DatItems.Formats
public ConfSetting()
{
_internal = new Models.Internal.ConfSetting();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.ConfSetting;
}
@@ -96,7 +98,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -103,6 +103,8 @@ namespace SabreTools.DatItems.Formats
public Configuration()
{
_internal = new Models.Internal.Configuration();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.Configuration;
}
@@ -119,7 +121,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -172,6 +172,8 @@ namespace SabreTools.DatItems.Formats
public Control()
{
_internal = new Models.Internal.Control();
Machine = new Machine();
ItemType = ItemType.Control;
}
@@ -187,7 +189,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -83,6 +83,8 @@ namespace SabreTools.DatItems.Formats
public DataArea()
{
_internal = new Models.Internal.DataArea();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.DataArea;
}
@@ -99,7 +101,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -110,6 +110,8 @@ namespace SabreTools.DatItems.Formats
public Device()
{
_internal = new Models.Internal.Device();
Machine = new Machine();
ItemType = ItemType.Device;
}
@@ -125,7 +127,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -42,6 +42,8 @@ namespace SabreTools.DatItems.Formats
public DeviceReference()
{
_internal = new Models.Internal.DeviceRef();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.DeviceReference;
}
@@ -58,7 +60,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -68,6 +68,8 @@ namespace SabreTools.DatItems.Formats
public DipLocation()
{
_internal = new Models.Internal.DipLocation();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.DipLocation;
}
@@ -84,7 +86,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -129,6 +129,8 @@ namespace SabreTools.DatItems.Formats
public DipSwitch()
{
_internal = new Models.Internal.DipSwitch();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.DipSwitch;
}
@@ -145,7 +147,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -80,6 +80,8 @@ namespace SabreTools.DatItems.Formats
public DipValue()
{
_internal = new Models.Internal.DipValue();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.DipValue;
}
@@ -96,7 +98,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -186,6 +186,8 @@ namespace SabreTools.DatItems.Formats
public Disk()
{
_internal = new Models.Internal.Disk();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.Disk;
DupeType = 0x00;
@@ -198,6 +200,8 @@ namespace SabreTools.DatItems.Formats
public Disk(BaseFile baseFile)
{
_internal = new Models.Internal.Disk();
Machine = new Machine();
Name = baseFile.Filename;
MD5 = TextHelper.ByteArrayToString(baseFile.MD5);
SHA1 = TextHelper.ByteArrayToString(baseFile.SHA1);
@@ -219,7 +223,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,
@@ -235,7 +239,7 @@ namespace SabreTools.DatItems.Formats
return new BaseFile()
{
Filename = this.Name,
Parent = this.Machine?.Name,
Parent = this.Machine.Name,
MD5 = TextHelper.StringToByteArray(this.MD5),
SHA1 = TextHelper.StringToByteArray(this.SHA1),
};
@@ -252,7 +256,7 @@ namespace SabreTools.DatItems.Formats
ItemType = ItemType.Rom,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -43,6 +43,8 @@ namespace SabreTools.DatItems.Formats
public DiskArea()
{
_internal = new Models.Internal.DiskArea();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.DiskArea;
}
@@ -59,7 +61,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -204,6 +204,8 @@ namespace SabreTools.DatItems.Formats
public Display()
{
_internal = new Models.Internal.Display();
Machine = new Machine();
ItemType = ItemType.Display;
}
@@ -219,7 +221,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -135,6 +135,8 @@ namespace SabreTools.DatItems.Formats
public Driver()
{
_internal = new Models.Internal.Driver();
Machine = new Machine();
ItemType = ItemType.Driver;
}
@@ -150,7 +152,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -42,6 +42,8 @@ namespace SabreTools.DatItems.Formats
public Extension()
{
_internal = new Models.Internal.Extension();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.Extension;
}
@@ -58,7 +60,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -66,6 +66,8 @@ namespace SabreTools.DatItems.Formats
public Feature()
{
_internal = new Models.Internal.Feature();
Machine = new Machine();
ItemType = ItemType.Feature;
}
@@ -81,7 +83,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -132,7 +132,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,
@@ -154,7 +154,7 @@ namespace SabreTools.DatItems.Formats
{
return new BaseFile()
{
Parent = this.Machine?.Name,
Parent = this.Machine.Name,
CRC = this._crc,
MD5 = this._md5,
SHA1 = this._sha1,
@@ -174,7 +174,7 @@ namespace SabreTools.DatItems.Formats
ItemType = ItemType.Rom,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -52,6 +52,8 @@ namespace SabreTools.DatItems.Formats
public Info()
{
_internal = new Models.Internal.Info();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.Info;
}
@@ -68,7 +70,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -89,6 +89,8 @@ namespace SabreTools.DatItems.Formats
public Input()
{
_internal = new Models.Internal.Input();
Machine = new Machine();
ItemType = ItemType.Input;
}
@@ -104,7 +106,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -52,6 +52,8 @@ namespace SabreTools.DatItems.Formats
public Instance()
{
_internal = new Models.Internal.Instance();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.Instance;
}
@@ -68,7 +70,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -85,6 +85,8 @@ namespace SabreTools.DatItems.Formats
public Media()
{
_internal = new Models.Internal.Media();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.Media;
DupeType = 0x00;
@@ -97,6 +99,8 @@ namespace SabreTools.DatItems.Formats
public Media(BaseFile baseFile)
{
_internal = new Models.Internal.Media();
Machine = new Machine();
Name = baseFile.Filename;
MD5 = TextHelper.ByteArrayToString(baseFile.MD5);
SHA1 = TextHelper.ByteArrayToString(baseFile.SHA1);
@@ -119,7 +123,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,
@@ -135,7 +139,7 @@ namespace SabreTools.DatItems.Formats
return new BaseFile()
{
Filename = this.Name,
Parent = this.Machine?.Name,
Parent = this.Machine.Name,
MD5 = TextHelper.StringToByteArray(this.MD5),
SHA1 = TextHelper.StringToByteArray(this.SHA1),
SHA256 = TextHelper.StringToByteArray(this.SHA256),
@@ -154,7 +158,7 @@ namespace SabreTools.DatItems.Formats
ItemType = ItemType.Rom,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,
};

View File

@@ -59,6 +59,8 @@ namespace SabreTools.DatItems.Formats
public Part()
{
_internal = new Models.Internal.Part();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.Part;
}
@@ -75,7 +77,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -52,6 +52,8 @@ namespace SabreTools.DatItems.Formats
public PartFeature()
{
_internal = new Models.Internal.Feature();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.PartFeature;
}
@@ -68,7 +70,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -47,6 +47,8 @@ namespace SabreTools.DatItems.Formats
public Port()
{
_internal = new Models.Internal.Port();
Machine = new Machine();
ItemType = ItemType.Port;
}
@@ -62,7 +64,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -65,6 +65,8 @@ namespace SabreTools.DatItems.Formats
public RamOption()
{
_internal = new Models.Internal.RamOption();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.RamOption;
}
@@ -81,7 +83,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -85,6 +85,8 @@ namespace SabreTools.DatItems.Formats
public Release()
{
_internal = new Models.Internal.Release();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.Release;
Region = string.Empty;
@@ -105,7 +107,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -131,7 +131,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -459,6 +459,8 @@ namespace SabreTools.DatItems.Formats
public Rom()
{
_internal = new Models.Internal.Rom();
Machine = new Machine();
Name = null;
ItemType = ItemType.Rom;
DupeType = 0x00;
@@ -493,6 +495,8 @@ namespace SabreTools.DatItems.Formats
public Rom(BaseFile baseFile)
{
_internal = new Models.Internal.Rom();
Machine = new Machine();
Name = baseFile.Filename;
Size = baseFile.Size;
CRC = TextHelper.ByteArrayToString(baseFile.CRC);
@@ -534,7 +538,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,
@@ -550,7 +554,7 @@ namespace SabreTools.DatItems.Formats
return new BaseFile()
{
Filename = this.Name,
Parent = this.Machine?.Name,
Parent = this.Machine.Name,
Date = this.Date,
Size = this.Size,
CRC = TextHelper.StringToByteArray(this.CRC),

View File

@@ -42,6 +42,8 @@ namespace SabreTools.DatItems.Formats
public Sample()
{
_internal = new Models.Internal.Sample();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.Sample;
}
@@ -58,7 +60,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -121,7 +121,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -52,6 +52,8 @@ namespace SabreTools.DatItems.Formats
public SharedFeature()
{
_internal = new Models.Internal.SharedFeat();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.SharedFeature;
}
@@ -68,7 +70,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -57,6 +57,8 @@ namespace SabreTools.DatItems.Formats
public Slot()
{
_internal = new Models.Internal.Slot();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.Slot;
}
@@ -73,7 +75,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -65,6 +65,8 @@ namespace SabreTools.DatItems.Formats
public SlotOption()
{
_internal = new Models.Internal.SlotOption();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.SlotOption;
}
@@ -81,7 +83,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -85,6 +85,8 @@ namespace SabreTools.DatItems.Formats
public SoftwareList()
{
_internal = new Models.Internal.SoftwareList();
Machine = new Machine();
Name = string.Empty;
ItemType = ItemType.SoftwareList;
}
@@ -100,7 +102,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -35,6 +35,8 @@ namespace SabreTools.DatItems.Formats
public Sound()
{
_internal = new Models.Internal.Sound();
Machine = new Machine();
ItemType = ItemType.Sound;
}
@@ -50,7 +52,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,

View File

@@ -158,7 +158,7 @@ namespace SabreTools.DatItems.Formats
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Machine = this.Machine.Clone() as Machine ?? new Machine(),
Source = this.Source?.Clone() as Source,
Remove = this.Remove,