mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] Reference reorganization
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using SabreTools.Helper.Data;
|
||||
|
||||
namespace SabreTools.Helper.Dats
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using SabreTools.Helper.Data;
|
||||
|
||||
namespace SabreTools.Helper.Dats
|
||||
|
||||
@@ -7,8 +7,10 @@ using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Xml;
|
||||
|
||||
using SabreTools.Helper.Data;
|
||||
using SabreTools.Helper.Tools;
|
||||
|
||||
using NaturalSort;
|
||||
using SharpCompress.Common;
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using SabreTools.Helper.Data;
|
||||
using SabreTools.Helper.Tools;
|
||||
|
||||
using NaturalSort;
|
||||
|
||||
namespace SabreTools.Helper.Dats
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
|
||||
namespace SabreTools.Helper.Dats
|
||||
{
|
||||
public class DatItemKV : IEquatable<DatItemKV>
|
||||
{
|
||||
// Private instance variables
|
||||
private string _name;
|
||||
private NameValueCollection _attributes;
|
||||
private NameValueCollection _machineAttributes;
|
||||
private NameValueCollection _machineElements;
|
||||
|
||||
// Public instance variables
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
public string Type
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
public string[] this[string s]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_attributes == null)
|
||||
{
|
||||
_attributes = new NameValueCollection();
|
||||
}
|
||||
|
||||
return _attributes.GetValues(s);
|
||||
}
|
||||
}
|
||||
|
||||
// Constructors
|
||||
public DatItemKV(string name)
|
||||
{
|
||||
_name = name;
|
||||
_attributes = new NameValueCollection();
|
||||
_machineAttributes = new NameValueCollection();
|
||||
_machineElements = new NameValueCollection();
|
||||
}
|
||||
|
||||
// Comparison methods
|
||||
public bool Equals(DatItemKV other)
|
||||
{
|
||||
// If the types don't match, then it's not the same
|
||||
if (_name != other.Type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise, loop through and compare against what you can
|
||||
bool success = true;
|
||||
foreach (string key in _attributes.Keys)
|
||||
{
|
||||
string[] vals = _attributes.GetValues(key);
|
||||
string[] ovals = other.GetValues(key);
|
||||
|
||||
// Special case for "rom"
|
||||
if (_name == "rom")
|
||||
{
|
||||
// If either is a nodump, it's never a match
|
||||
if (Get("status") == "nodump" || other.Get("status") == "nodump")
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
|
||||
// If the size is the same and any combination of metadata matches
|
||||
if ((Get("size") == other.Get("size")) &&
|
||||
((String.IsNullOrEmpty(Get("crc")) || String.IsNullOrEmpty(other.Get("crc"))) || Get("crc") == other.Get("crc")) &&
|
||||
((String.IsNullOrEmpty(Get("md5")) || String.IsNullOrEmpty(other.Get("md5"))) || Get("md5") == other.Get("md5")) &&
|
||||
((String.IsNullOrEmpty(Get("sha1")) || String.IsNullOrEmpty(other.Get("sha1"))) || Get("sha1") == other.Get("sha1")))
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
// Special case for "disk"
|
||||
else if (_name == "disk")
|
||||
{
|
||||
// If either is a nodump, it's never a match
|
||||
if (Get("status") == "nodump" || other.Get("status") == "nodump")
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
|
||||
// If any combination of metadata matches
|
||||
if (((String.IsNullOrEmpty(Get("md5")) || String.IsNullOrEmpty(other.Get("md5"))) || Get("md5") == other.Get("md5")) &&
|
||||
((String.IsNullOrEmpty(Get("sha1")) || String.IsNullOrEmpty(other.Get("sha1"))) || Get("sha1") == other.Get("sha1")))
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
// For everything else
|
||||
else
|
||||
{
|
||||
// http://stackoverflow.com/questions/649444/testing-equality-of-arrays-in-c-sharp
|
||||
var q = from a in vals
|
||||
join b in ovals on a equals b
|
||||
select a;
|
||||
|
||||
success &= vals.Length == ovals.Length && q.Count() == vals.Length;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
// Instance methods
|
||||
public void Add(string name, string value)
|
||||
{
|
||||
_attributes.Add(name, value);
|
||||
}
|
||||
public string Get(string name)
|
||||
{
|
||||
return _attributes.Get(name);
|
||||
}
|
||||
public string Get(int index)
|
||||
{
|
||||
return _attributes.Get(index);
|
||||
}
|
||||
public string[] GetValues(string name)
|
||||
{
|
||||
return _attributes.GetValues(name);
|
||||
}
|
||||
public string[] GetValues(int index)
|
||||
{
|
||||
return _attributes.GetValues(index);
|
||||
}
|
||||
|
||||
public void MachineAttributesAdd(string name, string value)
|
||||
{
|
||||
_machineAttributes.Add(name, value);
|
||||
}
|
||||
public string MachineAttributesGet(string name)
|
||||
{
|
||||
return _attributes.Get(name);
|
||||
}
|
||||
public string MachineAttributesGet(int index)
|
||||
{
|
||||
return _attributes.Get(index);
|
||||
}
|
||||
public string[] MachineAttributesGetValues(string name)
|
||||
{
|
||||
return _attributes.GetValues(name);
|
||||
}
|
||||
public string[] MachineAttributesGetValues(int index)
|
||||
{
|
||||
return _attributes.GetValues(index);
|
||||
}
|
||||
|
||||
public void MachineElementsAdd(string name, string value)
|
||||
{
|
||||
_machineAttributes.Add(name, value);
|
||||
}
|
||||
public string MachineElementsGet(string name)
|
||||
{
|
||||
return _attributes.Get(name);
|
||||
}
|
||||
public string MachineElementsGet(int index)
|
||||
{
|
||||
return _attributes.Get(index);
|
||||
}
|
||||
public string[] MachineElementsGetValues(string name)
|
||||
{
|
||||
return _attributes.GetValues(name);
|
||||
}
|
||||
public string[] MachineElementsGetValues(int index)
|
||||
{
|
||||
return _attributes.GetValues(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using SabreTools.Helper.Data;
|
||||
|
||||
namespace SabreTools.Helper.Dats
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using SabreTools.Helper.Data;
|
||||
|
||||
namespace SabreTools.Helper.Dats
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using SabreTools.Helper.Data;
|
||||
|
||||
namespace SabreTools.Helper.Dats
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using SabreTools.Helper.Data;
|
||||
|
||||
namespace SabreTools.Helper.Dats
|
||||
|
||||
@@ -106,7 +106,6 @@
|
||||
<Compile Include="Dats\BiosSet.cs" />
|
||||
<Compile Include="Dats\DatFile.cs" />
|
||||
<Compile Include="Dats\DatItem.cs" />
|
||||
<Compile Include="Dats\DatItemKV.cs" />
|
||||
<Compile Include="Dats\Disk.cs" />
|
||||
<Compile Include="Dats\Machine.cs" />
|
||||
<Compile Include="Dats\Release.cs" />
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
using SabreTools.Helper.Data;
|
||||
using SabreTools.Helper.Tools;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using SabreTools.Helper.Data;
|
||||
|
||||
namespace SabreTools.Helper.Skippers
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using Mono.Data.Sqlite;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using SabreTools.Helper.Data;
|
||||
using Mono.Data.Sqlite;
|
||||
|
||||
namespace SabreTools.Helper.Tools
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Mono.Data.Sqlite;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -6,10 +7,11 @@ using System.Security.Cryptography;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
|
||||
using SabreTools.Helper.Data;
|
||||
using SabreTools.Helper.Dats;
|
||||
using SabreTools.Helper.Skippers;
|
||||
using Mono.Data.Sqlite;
|
||||
|
||||
using NaturalSort;
|
||||
using OCRC;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
|
||||
using SabreTools.Helper.Data;
|
||||
using SabreTools.Helper.Dats;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using SabreTools.Helper;
|
||||
using SabreTools.Helper.Data;
|
||||
using SabreTools.Helper.Dats;
|
||||
|
||||
Reference in New Issue
Block a user