[DatItems/] Clean these up a bit

This commit is contained in:
Matt Nadareski
2019-01-08 17:40:12 -08:00
parent 1768370199
commit 26c4e1a93f
7 changed files with 857 additions and 853 deletions

View File

@@ -14,8 +14,8 @@ namespace SabreTools.Library.DatItems
/// </summary>
public Archive()
{
_name = "";
_itemType = ItemType.Archive;
this.Name = "";
this.ItemType = ItemType.Archive;
}
#endregion
@@ -68,7 +68,7 @@ namespace SabreTools.Library.DatItems
public override bool Equals(DatItem other)
{
// If we don't have an archive, return false
if (_itemType != other.ItemType)
if (this.ItemType != other.ItemType)
{
return false;
}
@@ -77,7 +77,7 @@ namespace SabreTools.Library.DatItems
Archive newOther = (Archive)other;
// If the archive information matches
return (_name == newOther.Name);
return (this.Name == newOther.Name);
}
#endregion

View File

@@ -7,25 +7,17 @@ namespace SabreTools.Library.DatItems
/// </summary>
public class BiosSet : DatItem
{
#region Private instance variables
private string _description;
private bool? _default;
#endregion
#region Publicly facing variables
public string Description
{
get { return _description; }
set { _description = value; }
}
public bool? Default
{
get { return _default; }
set { _default = value; }
}
/// <summary>
/// Description of the BIOS
/// </summary>
public string Description { get; set; }
/// <summary>
/// Determine whether the BIOS is default
/// </summary>
public bool? Default { get; set; }
#endregion
@@ -36,8 +28,8 @@ namespace SabreTools.Library.DatItems
/// </summary>
public BiosSet()
{
_name = "";
_itemType = ItemType.BiosSet;
this.Name = "";
this.ItemType = ItemType.BiosSet;
}
#endregion
@@ -93,7 +85,7 @@ namespace SabreTools.Library.DatItems
public override bool Equals(DatItem other)
{
// If we don't have a biosset, return false
if (_itemType != other.ItemType)
if (this.ItemType != other.ItemType)
{
return false;
}
@@ -102,7 +94,7 @@ namespace SabreTools.Library.DatItems
BiosSet newOther = (BiosSet)other;
// If the archive information matches
return (_name == newOther.Name && _description == newOther.Description && _default == newOther.Default);
return (this.Name == newOther.Name && this.Description == newOther.Description && this.Default == newOther.Default);
}
#endregion

View File

@@ -14,8 +14,8 @@ namespace SabreTools.Library.DatItems
/// </summary>
public Blank()
{
_name = "";
_itemType = ItemType.Blank;
this.Name = "";
this.ItemType = ItemType.Blank;
}
#endregion
@@ -68,7 +68,7 @@ namespace SabreTools.Library.DatItems
public override bool Equals(DatItem other)
{
// If we don't have a blank, return false
if (_itemType != other.ItemType)
if (this.ItemType != other.ItemType)
{
return false;
}

View File

@@ -1,5 +1,4 @@
using System.Linq;
using SabreTools.Library.Data;
using SabreTools.Library.FileTypes;
using SabreTools.Library.Tools;
@@ -13,79 +12,90 @@ namespace SabreTools.Library.DatItems
{
#region Private instance variables
// Disk information
private byte[] _md5; // 16 bytes
private byte[] _sha1; // 20 bytes
private byte[] _sha256; // 32 bytes
private byte[] _sha384; // 48 bytes
private byte[] _sha512; // 64 bytes
private string _merge;
private string _region;
private string _index;
private bool? _writable;
private ItemStatus _itemStatus;
private bool? _optional;
#endregion
#region Publicly facing variables
// Disk information
/// <summary>
/// Data MD5 hash
/// </summary>
public string MD5
{
get { return _md5.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_md5); }
set { _md5 = Utilities.StringToByteArray(value); }
}
/// <summary>
/// Data SHA-1 hash
/// </summary>
public string SHA1
{
get { return _sha1.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha1); }
set { _sha1 = Utilities.StringToByteArray(value); }
}
/// <summary>
/// Data SHA-256 hash
/// </summary>
public string SHA256
{
get { return _sha256.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha256); }
set { _sha256 = Utilities.StringToByteArray(value); }
}
/// <summary>
/// Data SHA-384 hash
/// </summary>
public string SHA384
{
get { return _sha384.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha384); }
set { _sha384 = Utilities.StringToByteArray(value); }
}
/// <summary>
/// Data SHA-512 hash
/// </summary>
public string SHA512
{
get { return _sha512.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha512); }
set { _sha512 = Utilities.StringToByteArray(value); }
}
public string MergeTag
{
get { return _merge; }
set { _merge = value; }
}
public string Region
{
get { return _region; }
set { _region = value; }
}
public string Index
{
get { return _index; }
set { _index = value; }
}
public bool? Writable
{
get { return _writable; }
set { _writable = value; }
}
public ItemStatus ItemStatus
{
get { return _itemStatus; }
set { _itemStatus = value; }
}
public bool? Optional
{
get { return _optional; }
set { _optional = value; }
}
/// <summary>
/// Disk name to merge from parent
/// </summary>
public string MergeTag { get; set; }
/// <summary>
/// Disk region
/// </summary>
public string Region { get; set; }
/// <summary>
/// Disk index
/// </summary>
public string Index { get; set; }
/// <summary>
/// Disk writable flag
/// </summary>
public bool? Writable { get; set; }
/// <summary>
/// Disk dump status
/// </summary>
public ItemStatus ItemStatus { get; set; }
/// <summary>
/// Determine if the disk is optional in the set
/// </summary>
public bool? Optional { get; set; }
#endregion
@@ -96,10 +106,10 @@ namespace SabreTools.Library.DatItems
/// </summary>
public Disk()
{
_name = "";
_itemType = ItemType.Disk;
_dupeType = 0x00;
_itemStatus = ItemStatus.None;
this.Name = "";
this.ItemType = ItemType.Disk;
this.DupeType = 0x00;
this.ItemStatus = ItemStatus.None;
}
/// <summary>
@@ -108,16 +118,16 @@ namespace SabreTools.Library.DatItems
/// <param name="baseFile"></param>
public Disk(BaseFile baseFile)
{
_name = baseFile.Filename;
this.Name = baseFile.Filename;
_md5 = baseFile.MD5;
_sha1 = baseFile.SHA1;
_sha256 = baseFile.SHA256;
_sha384 = baseFile.SHA384;
_sha512 = baseFile.SHA512;
_itemType = ItemType.Disk;
_dupeType = 0x00;
_itemStatus = ItemStatus.None;
this.ItemType = ItemType.Disk;
this.DupeType = 0x00;
this.ItemStatus = ItemStatus.None;
}
#endregion
@@ -179,7 +189,7 @@ namespace SabreTools.Library.DatItems
bool dupefound = false;
// If we don't have a rom, return false
if (_itemType != other.ItemType)
if (this.ItemType != other.ItemType)
{
return dupefound;
}
@@ -188,8 +198,8 @@ namespace SabreTools.Library.DatItems
Disk newOther = (Disk)other;
// If all hashes are empty but they're both nodump and the names match, then they're dupes
if ((this._itemStatus == ItemStatus.Nodump && newOther._itemStatus == ItemStatus.Nodump)
&& (this._name == newOther._name)
if ((this.ItemStatus == ItemStatus.Nodump && newOther.ItemStatus == ItemStatus.Nodump)
&& (this.Name == newOther.Name)
&& (this._md5.IsNullOrWhiteSpace() && newOther._md5.IsNullOrWhiteSpace())
&& (this._sha1.IsNullOrWhiteSpace() && newOther._sha1.IsNullOrWhiteSpace())
&& (this._sha256.IsNullOrWhiteSpace() && newOther._sha256.IsNullOrWhiteSpace())

View File

@@ -7,37 +7,27 @@ namespace SabreTools.Library.DatItems
/// </summary>
public class Release : DatItem
{
#region Private instance variables
private string _region;
private string _language;
private string _date;
private bool? _default;
#endregion
#region Publicly facing variables
public string Region
{
get { return _region; }
set { _region = value; }
}
public string Language
{
get { return _language; }
set { _language = value; }
}
public string Date
{
get { return _date; }
set { _date = value; }
}
public bool? Default
{
get { return _default; }
set { _default = value; }
}
/// <summary>
/// Release region(s)
/// </summary>
public string Region { get; set; }
/// <summary>
/// Release language(s)
/// </summary>
public string Language { get; set; }
/// <summary>
/// Date of release
/// </summary>
public string Date { get; set; }
/// <summary>
/// Default release, if applicable
/// </summary>
public bool? Default { get; set; }
#endregion
@@ -48,12 +38,12 @@ namespace SabreTools.Library.DatItems
/// </summary>
public Release()
{
_name = "";
_itemType = ItemType.Release;
_region = "";
_language = "";
_date = "";
_default = null;
this.Name = "";
this.ItemType = ItemType.Release;
this.Region = "";
this.Language = "";
this.Date = "";
this.Default = null;
}
#endregion
@@ -111,7 +101,7 @@ namespace SabreTools.Library.DatItems
public override bool Equals(DatItem other)
{
// If we don't have a release return false
if (_itemType != other.ItemType)
if (this.ItemType != other.ItemType)
{
return false;
}
@@ -120,11 +110,11 @@ namespace SabreTools.Library.DatItems
Release newOther = (Release)other;
// If the archive information matches
return (_name == newOther.Name
&& _region == newOther.Region
&& _language == newOther.Language
&& _date == newOther.Date
&& _default == newOther.Default);
return (this.Name == newOther.Name
&& this.Region == newOther.Region
&& this.Language == newOther.Language
&& this.Date == newOther.Date
&& this.Default == newOther.Default);
}
#endregion

View File

@@ -1,5 +1,4 @@
using System.Linq;
using SabreTools.Library.Data;
using SabreTools.Library.FileTypes;
using SabreTools.Library.Tools;
@@ -13,98 +12,111 @@ namespace SabreTools.Library.DatItems
{
#region Private instance variables
// Rom information
private string _bios;
private long _size;
private byte[] _crc; // 8 bytes
private byte[] _md5; // 16 bytes
private byte[] _sha1; // 20 bytes
private byte[] _sha256; // 32 bytes
private byte[] _sha384; // 48 bytes
private byte[] _sha512; // 64 bytes
private string _merge;
private string _region;
private string _offset;
private string _date;
private ItemStatus _itemStatus;
private bool? _optional;
#endregion
#region Publicly facing variables
// Rom information
public string Bios
{
get { return _bios; }
set { _bios = value; }
}
public long Size
{
get { return _size; }
set { _size = value; }
}
/// <summary>
/// What BIOS is required for this rom
/// </summary>
public string Bios { get; set; }
/// <summary>
/// Byte size of the rom
/// </summary>
public long Size { get; set; }
/// <summary>
/// File CRC32 hash
/// </summary>
public string CRC
{
get { return _crc.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_crc); }
set { _crc = (value == "null" ? Constants.CRCZeroBytes : Utilities.StringToByteArray(value)); }
}
/// <summary>
/// File MD5 hash
/// </summary>
public string MD5
{
get { return _md5.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_md5); }
set { _md5 = (value == "null" ? Constants.MD5ZeroBytes : Utilities.StringToByteArray(value)); }
set { _md5 = Utilities.StringToByteArray(value); }
}
/// <summary>
/// File SHA-1 hash
/// </summary>
public string SHA1
{
get { return _sha1.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha1); }
set { _sha1 = (value == "null" ? Constants.SHA1ZeroBytes : Utilities.StringToByteArray(value)); }
set { _sha1 = Utilities.StringToByteArray(value); }
}
/// <summary>
/// File SHA-256 hash
/// </summary>
public string SHA256
{
get { return _sha256.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha256); }
set { _sha256 = (value == "null" ? Constants.SHA256ZeroBytes : Utilities.StringToByteArray(value)); }
set { _sha256 = Utilities.StringToByteArray(value); }
}
/// <summary>
/// File SHA-384 hash
/// </summary>
public string SHA384
{
get { return _sha384.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha384); }
set { _sha384 = (value == "null" ? Constants.SHA384ZeroBytes : Utilities.StringToByteArray(value)); }
set { _sha384 = Utilities.StringToByteArray(value); }
}
/// <summary>
/// File SHA-512 hash
/// </summary>
public string SHA512
{
get { return _sha512.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha512); }
set { _sha512 = (value == "null" ? Constants.SHA512ZeroBytes : Utilities.StringToByteArray(value)); }
}
public string MergeTag
{
get { return _merge; }
set { _merge = value; }
}
public string Region
{
get { return _region; }
set { _region = value; }
}
public string Offset
{
get { return _offset; }
set { _offset = value; }
}
public string Date
{
get { return _date; }
set { _date = value; }
}
public ItemStatus ItemStatus
{
get { return _itemStatus; }
set { _itemStatus = value; }
}
public bool? Optional
{
get { return _optional; }
set { _optional = value; }
set { _sha512 = Utilities.StringToByteArray(value); }
}
/// <summary>
/// Rom name to merge from parent
/// </summary>
public string MergeTag { get; set; }
/// <summary>
/// Rom region
/// </summary>
public string Region { get; set; }
/// <summary>
/// Data offset within rom
/// </summary>
public string Offset { get; set; }
/// <summary>
/// File created date
/// </summary>
public string Date { get; set; }
/// <summary>
/// Rom dump status
/// </summary>
public ItemStatus ItemStatus { get; set; }
/// <summary>
/// Determine if the rom is optional in the set
/// </summary>
public bool? Optional { get; set; }
#endregion
#region Constructors
@@ -114,11 +126,11 @@ namespace SabreTools.Library.DatItems
/// </summary>
public Rom()
{
_name = "";
_itemType = ItemType.Rom;
_dupeType = 0x00;
_itemStatus = ItemStatus.None;
_date = "";
this.Name = "";
this.ItemType = ItemType.Rom;
this.DupeType = 0x00;
this.ItemStatus = ItemStatus.None;
this.Date = "";
}
/// <summary>
@@ -130,9 +142,9 @@ namespace SabreTools.Library.DatItems
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
public Rom(string name, string machineName, Hash omitFromScan = Hash.DeepHashes)
{
_name = name;
_itemType = ItemType.Rom;
_size = -1;
this.Name = name;
this.ItemType = ItemType.Rom;
this.Size = -1;
if ((omitFromScan & Hash.CRC) == 0)
{
_crc = null;
@@ -157,7 +169,7 @@ namespace SabreTools.Library.DatItems
{
_sha512 = null;
}
_itemStatus = ItemStatus.None;
this.ItemStatus = ItemStatus.None;
_machine = new Machine
{
@@ -172,8 +184,8 @@ namespace SabreTools.Library.DatItems
/// <param name="baseFile"></param>
public Rom(BaseFile baseFile)
{
_name = baseFile.Filename;
_size = baseFile.Size ?? -1;
this.Name = baseFile.Filename;
this.Size = baseFile.Size ?? -1;
_crc = baseFile.CRC;
_md5 = baseFile.MD5;
_sha1 = baseFile.SHA1;
@@ -181,10 +193,10 @@ namespace SabreTools.Library.DatItems
_sha384 = baseFile.SHA384;
_sha512 = baseFile.SHA512;
_itemType = ItemType.Rom;
_dupeType = 0x00;
_itemStatus = ItemStatus.None;
_date = baseFile.Date;
this.ItemType = ItemType.Rom;
this.DupeType = 0x00;
this.ItemStatus = ItemStatus.None;
this.Date = baseFile.Date;
}
#endregion
@@ -249,7 +261,7 @@ namespace SabreTools.Library.DatItems
bool dupefound = false;
// If we don't have a rom, return false
if (_itemType != other.ItemType)
if (this.ItemType != other.ItemType)
{
return dupefound;
}
@@ -258,8 +270,8 @@ namespace SabreTools.Library.DatItems
Rom newOther = (Rom)other;
// If all hashes are empty but they're both nodump and the names match, then they're dupes
if ((this._itemStatus == ItemStatus.Nodump && newOther._itemStatus == ItemStatus.Nodump)
&& (this._name == newOther._name)
if ((this.ItemStatus == ItemStatus.Nodump && newOther.ItemStatus == ItemStatus.Nodump)
&& (this.Name == newOther.Name)
&& (this._crc.IsNullOrWhiteSpace() && newOther._crc.IsNullOrWhiteSpace())
&& (this._md5.IsNullOrWhiteSpace() && newOther._md5.IsNullOrWhiteSpace())
&& (this._sha1.IsNullOrWhiteSpace() && newOther._sha1.IsNullOrWhiteSpace())

View File

@@ -14,8 +14,8 @@ namespace SabreTools.Library.DatItems
/// </summary>
public Sample()
{
_name = "";
_itemType = ItemType.Sample;
this.Name = "";
this.ItemType = ItemType.Sample;
}
#endregion
@@ -68,7 +68,7 @@ namespace SabreTools.Library.DatItems
public override bool Equals(DatItem other)
{
// If we don't have a sample, return false
if (_itemType != other.ItemType)
if (this.ItemType != other.ItemType)
{
return false;
}
@@ -77,7 +77,7 @@ namespace SabreTools.Library.DatItems
Sample newOther = (Sample)other;
// If the archive information matches
return (_name == newOther.Name);
return (this.Name == newOther.Name);
}
#endregion