mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix some over-accessible fields
This commit is contained in:
@@ -14,29 +14,17 @@ namespace SabreTools.Core.Filter
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Key name for the filter
|
/// Key name for the filter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
#if NETFRAMEWORK || NETCOREAPP3_1
|
public string[] Key { get; }
|
||||||
public string[] Key { get; private set; }
|
|
||||||
#else
|
|
||||||
public string[] Key { get; init; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Value to match in the filter
|
/// Value to match in the filter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
#if NETFRAMEWORK || NETCOREAPP3_1
|
public string? Value { get; }
|
||||||
public string? Value { get; private set; }
|
|
||||||
#else
|
|
||||||
public string? Value { get; init; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Operation on how to match the filter
|
/// Operation on how to match the filter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
#if NETFRAMEWORK || NETCOREAPP3_1
|
public Operation Operation { get; }
|
||||||
public Operation Operation { get; private set; }
|
|
||||||
#else
|
|
||||||
public Operation Operation { get; init; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public FilterObject(string filterString)
|
public FilterObject(string filterString)
|
||||||
{
|
{
|
||||||
@@ -48,9 +36,9 @@ namespace SabreTools.Core.Filter
|
|||||||
if (itemName == null || fieldName == null)
|
if (itemName == null || fieldName == null)
|
||||||
throw new ArgumentOutOfRangeException(nameof(filterString));
|
throw new ArgumentOutOfRangeException(nameof(filterString));
|
||||||
|
|
||||||
this.Key = [itemName, fieldName];
|
Key = [itemName, fieldName];
|
||||||
this.Value = value;
|
Value = value;
|
||||||
this.Operation = operation;
|
Operation = operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FilterObject(string itemField, string? value, string? operation)
|
public FilterObject(string itemField, string? value, string? operation)
|
||||||
@@ -59,9 +47,9 @@ namespace SabreTools.Core.Filter
|
|||||||
if (itemName == null || fieldName == null)
|
if (itemName == null || fieldName == null)
|
||||||
throw new ArgumentOutOfRangeException(nameof(value));
|
throw new ArgumentOutOfRangeException(nameof(value));
|
||||||
|
|
||||||
this.Key = [itemName, fieldName];
|
Key = [itemName, fieldName];
|
||||||
this.Value = value;
|
Value = value;
|
||||||
this.Operation = GetOperation(operation);
|
Operation = GetOperation(operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FilterObject(string itemField, string? value, Operation operation)
|
public FilterObject(string itemField, string? value, Operation operation)
|
||||||
@@ -70,9 +58,9 @@ namespace SabreTools.Core.Filter
|
|||||||
if (itemName == null || fieldName == null)
|
if (itemName == null || fieldName == null)
|
||||||
throw new ArgumentOutOfRangeException(nameof(value));
|
throw new ArgumentOutOfRangeException(nameof(value));
|
||||||
|
|
||||||
this.Key = [itemName, fieldName];
|
Key = [itemName, fieldName];
|
||||||
this.Value = value;
|
Value = value;
|
||||||
this.Operation = operation;
|
Operation = operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Matching
|
#region Matching
|
||||||
@@ -82,8 +70,8 @@ namespace SabreTools.Core.Filter
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Matches(DictionaryBase dictionaryBase)
|
public bool Matches(DictionaryBase dictionaryBase)
|
||||||
{
|
{
|
||||||
// TODO: Add validation of dictionary base type from this.Key[0]
|
// TODO: Add validation of dictionary base type from Key[0]
|
||||||
return this.Operation switch
|
return Operation switch
|
||||||
{
|
{
|
||||||
Operation.Equals => MatchesEqual(dictionaryBase),
|
Operation.Equals => MatchesEqual(dictionaryBase),
|
||||||
Operation.NotEquals => MatchesNotEqual(dictionaryBase),
|
Operation.NotEquals => MatchesNotEqual(dictionaryBase),
|
||||||
@@ -101,41 +89,41 @@ namespace SabreTools.Core.Filter
|
|||||||
private bool MatchesEqual(DictionaryBase dictionaryBase)
|
private bool MatchesEqual(DictionaryBase dictionaryBase)
|
||||||
{
|
{
|
||||||
// If the key doesn't exist, we count it as null
|
// If the key doesn't exist, we count it as null
|
||||||
if (!dictionaryBase.ContainsKey(this.Key[1]))
|
if (!dictionaryBase.ContainsKey(Key[1]))
|
||||||
return this.Value == null;
|
return Value == null;
|
||||||
|
|
||||||
// If the value in the dictionary is null
|
// If the value in the dictionary is null
|
||||||
string? checkValue = dictionaryBase.ReadString(this.Key[1]);
|
string? checkValue = dictionaryBase.ReadString(Key[1]);
|
||||||
if (checkValue == null)
|
if (checkValue == null)
|
||||||
return this.Value == null;
|
return Value == null;
|
||||||
|
|
||||||
// If we have both a potentally boolean check and value
|
// If we have both a potentally boolean check and value
|
||||||
bool? checkValueBool = ConvertToBoolean(checkValue);
|
bool? checkValueBool = ConvertToBoolean(checkValue);
|
||||||
bool? matchValueBool = ConvertToBoolean(this.Value);
|
bool? matchValueBool = ConvertToBoolean(Value);
|
||||||
if (checkValueBool != null && matchValueBool != null)
|
if (checkValueBool != null && matchValueBool != null)
|
||||||
return checkValueBool == matchValueBool;
|
return checkValueBool == matchValueBool;
|
||||||
|
|
||||||
// If we have both a potentially numeric check and value
|
// If we have both a potentially numeric check and value
|
||||||
if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(this.Value))
|
if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(Value))
|
||||||
{
|
{
|
||||||
// Check Int64 values
|
// Check Int64 values
|
||||||
long? checkValueLong = NumberHelper.ConvertToInt64(checkValue);
|
long? checkValueLong = NumberHelper.ConvertToInt64(checkValue);
|
||||||
long? matchValueLong = NumberHelper.ConvertToInt64(this.Value);
|
long? matchValueLong = NumberHelper.ConvertToInt64(Value);
|
||||||
if (checkValueLong != null && matchValueLong != null)
|
if (checkValueLong != null && matchValueLong != null)
|
||||||
return checkValueLong == matchValueLong;
|
return checkValueLong == matchValueLong;
|
||||||
|
|
||||||
// Check Double values
|
// Check Double values
|
||||||
double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue);
|
double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue);
|
||||||
double? matchValueDouble = NumberHelper.ConvertToDouble(this.Value);
|
double? matchValueDouble = NumberHelper.ConvertToDouble(Value);
|
||||||
if (checkValueDouble != null && matchValueDouble != null)
|
if (checkValueDouble != null && matchValueDouble != null)
|
||||||
return checkValueDouble == matchValueDouble;
|
return checkValueDouble == matchValueDouble;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the value might contain valid Regex
|
// If the value might contain valid Regex
|
||||||
if (this.Value != null && ContainsRegex(this.Value))
|
if (Value != null && ContainsRegex(Value))
|
||||||
return Regex.IsMatch(checkValue, this.Value);
|
return Regex.IsMatch(checkValue, Value);
|
||||||
|
|
||||||
return string.Equals(checkValue, this.Value, StringComparison.OrdinalIgnoreCase);
|
return string.Equals(checkValue, Value, StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -144,41 +132,41 @@ namespace SabreTools.Core.Filter
|
|||||||
private bool MatchesNotEqual(DictionaryBase dictionaryBase)
|
private bool MatchesNotEqual(DictionaryBase dictionaryBase)
|
||||||
{
|
{
|
||||||
// If the key doesn't exist, we count it as null
|
// If the key doesn't exist, we count it as null
|
||||||
if (!dictionaryBase.ContainsKey(this.Key[1]))
|
if (!dictionaryBase.ContainsKey(Key[1]))
|
||||||
return this.Value != null;
|
return Value != null;
|
||||||
|
|
||||||
// If the value in the dictionary is null
|
// If the value in the dictionary is null
|
||||||
string? checkValue = dictionaryBase.ReadString(this.Key[1]);
|
string? checkValue = dictionaryBase.ReadString(Key[1]);
|
||||||
if (checkValue == null)
|
if (checkValue == null)
|
||||||
return this.Value == null;
|
return Value == null;
|
||||||
|
|
||||||
// If we have both a potentally boolean check and value
|
// If we have both a potentally boolean check and value
|
||||||
bool? checkValueBool = ConvertToBoolean(checkValue);
|
bool? checkValueBool = ConvertToBoolean(checkValue);
|
||||||
bool? matchValueBool = ConvertToBoolean(this.Value);
|
bool? matchValueBool = ConvertToBoolean(Value);
|
||||||
if (checkValueBool != null && matchValueBool != null)
|
if (checkValueBool != null && matchValueBool != null)
|
||||||
return checkValueBool != matchValueBool;
|
return checkValueBool != matchValueBool;
|
||||||
|
|
||||||
// If we have both a potentially numeric check and value
|
// If we have both a potentially numeric check and value
|
||||||
if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(this.Value))
|
if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(Value))
|
||||||
{
|
{
|
||||||
// Check Int64 values
|
// Check Int64 values
|
||||||
long? checkValueLong = NumberHelper.ConvertToInt64(checkValue);
|
long? checkValueLong = NumberHelper.ConvertToInt64(checkValue);
|
||||||
long? matchValueLong = NumberHelper.ConvertToInt64(this.Value);
|
long? matchValueLong = NumberHelper.ConvertToInt64(Value);
|
||||||
if (checkValueLong != null && matchValueLong != null)
|
if (checkValueLong != null && matchValueLong != null)
|
||||||
return checkValueLong != matchValueLong;
|
return checkValueLong != matchValueLong;
|
||||||
|
|
||||||
// Check Double values
|
// Check Double values
|
||||||
double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue);
|
double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue);
|
||||||
double? matchValueDouble = NumberHelper.ConvertToDouble(this.Value);
|
double? matchValueDouble = NumberHelper.ConvertToDouble(Value);
|
||||||
if (checkValueDouble != null && matchValueDouble != null)
|
if (checkValueDouble != null && matchValueDouble != null)
|
||||||
return checkValueDouble != matchValueDouble;
|
return checkValueDouble != matchValueDouble;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the value might contain valid Regex
|
// If the value might contain valid Regex
|
||||||
if (this.Value != null && ContainsRegex(this.Value))
|
if (Value != null && ContainsRegex(Value))
|
||||||
return !Regex.IsMatch(checkValue, this.Value);
|
return !Regex.IsMatch(checkValue, Value);
|
||||||
|
|
||||||
return !string.Equals(checkValue, this.Value, StringComparison.OrdinalIgnoreCase);
|
return !string.Equals(checkValue, Value, StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -187,26 +175,26 @@ namespace SabreTools.Core.Filter
|
|||||||
private bool MatchesGreaterThan(DictionaryBase dictionaryBase)
|
private bool MatchesGreaterThan(DictionaryBase dictionaryBase)
|
||||||
{
|
{
|
||||||
// If the key doesn't exist, we count it as null
|
// If the key doesn't exist, we count it as null
|
||||||
if (!dictionaryBase.ContainsKey(this.Key[1]))
|
if (!dictionaryBase.ContainsKey(Key[1]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If the value in the dictionary is null
|
// If the value in the dictionary is null
|
||||||
string? checkValue = dictionaryBase.ReadString(this.Key[1]);
|
string? checkValue = dictionaryBase.ReadString(Key[1]);
|
||||||
if (checkValue == null)
|
if (checkValue == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If we have both a potentially numeric check and value
|
// If we have both a potentially numeric check and value
|
||||||
if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(this.Value))
|
if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(Value))
|
||||||
{
|
{
|
||||||
// Check Int64 values
|
// Check Int64 values
|
||||||
long? checkValueLong = NumberHelper.ConvertToInt64(checkValue);
|
long? checkValueLong = NumberHelper.ConvertToInt64(checkValue);
|
||||||
long? matchValueLong = NumberHelper.ConvertToInt64(this.Value);
|
long? matchValueLong = NumberHelper.ConvertToInt64(Value);
|
||||||
if (checkValueLong != null && matchValueLong != null)
|
if (checkValueLong != null && matchValueLong != null)
|
||||||
return checkValueLong > matchValueLong;
|
return checkValueLong > matchValueLong;
|
||||||
|
|
||||||
// Check Double values
|
// Check Double values
|
||||||
double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue);
|
double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue);
|
||||||
double? matchValueDouble = NumberHelper.ConvertToDouble(this.Value);
|
double? matchValueDouble = NumberHelper.ConvertToDouble(Value);
|
||||||
if (checkValueDouble != null && matchValueDouble != null)
|
if (checkValueDouble != null && matchValueDouble != null)
|
||||||
return checkValueDouble > matchValueDouble;
|
return checkValueDouble > matchValueDouble;
|
||||||
}
|
}
|
||||||
@@ -220,26 +208,26 @@ namespace SabreTools.Core.Filter
|
|||||||
private bool MatchesGreaterThanOrEqual(DictionaryBase dictionaryBase)
|
private bool MatchesGreaterThanOrEqual(DictionaryBase dictionaryBase)
|
||||||
{
|
{
|
||||||
// If the key doesn't exist, we count it as null
|
// If the key doesn't exist, we count it as null
|
||||||
if (!dictionaryBase.ContainsKey(this.Key[1]))
|
if (!dictionaryBase.ContainsKey(Key[1]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If the value in the dictionary is null
|
// If the value in the dictionary is null
|
||||||
string? checkValue = dictionaryBase.ReadString(this.Key[1]);
|
string? checkValue = dictionaryBase.ReadString(Key[1]);
|
||||||
if (checkValue == null)
|
if (checkValue == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If we have both a potentially numeric check and value
|
// If we have both a potentially numeric check and value
|
||||||
if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(this.Value))
|
if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(Value))
|
||||||
{
|
{
|
||||||
// Check Int64 values
|
// Check Int64 values
|
||||||
long? checkValueLong = NumberHelper.ConvertToInt64(checkValue);
|
long? checkValueLong = NumberHelper.ConvertToInt64(checkValue);
|
||||||
long? matchValueLong = NumberHelper.ConvertToInt64(this.Value);
|
long? matchValueLong = NumberHelper.ConvertToInt64(Value);
|
||||||
if (checkValueLong != null && matchValueLong != null)
|
if (checkValueLong != null && matchValueLong != null)
|
||||||
return checkValueLong >= matchValueLong;
|
return checkValueLong >= matchValueLong;
|
||||||
|
|
||||||
// Check Double values
|
// Check Double values
|
||||||
double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue);
|
double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue);
|
||||||
double? matchValueDouble = NumberHelper.ConvertToDouble(this.Value);
|
double? matchValueDouble = NumberHelper.ConvertToDouble(Value);
|
||||||
if (checkValueDouble != null && matchValueDouble != null)
|
if (checkValueDouble != null && matchValueDouble != null)
|
||||||
return checkValueDouble >= matchValueDouble;
|
return checkValueDouble >= matchValueDouble;
|
||||||
}
|
}
|
||||||
@@ -253,26 +241,26 @@ namespace SabreTools.Core.Filter
|
|||||||
private bool MatchesLessThan(DictionaryBase dictionaryBase)
|
private bool MatchesLessThan(DictionaryBase dictionaryBase)
|
||||||
{
|
{
|
||||||
// If the key doesn't exist, we count it as null
|
// If the key doesn't exist, we count it as null
|
||||||
if (!dictionaryBase.ContainsKey(this.Key[1]))
|
if (!dictionaryBase.ContainsKey(Key[1]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If the value in the dictionary is null
|
// If the value in the dictionary is null
|
||||||
string? checkValue = dictionaryBase.ReadString(this.Key[1]);
|
string? checkValue = dictionaryBase.ReadString(Key[1]);
|
||||||
if (checkValue == null)
|
if (checkValue == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If we have both a potentially numeric check and value
|
// If we have both a potentially numeric check and value
|
||||||
if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(this.Value))
|
if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(Value))
|
||||||
{
|
{
|
||||||
// Check Int64 values
|
// Check Int64 values
|
||||||
long? checkValueLong = NumberHelper.ConvertToInt64(checkValue);
|
long? checkValueLong = NumberHelper.ConvertToInt64(checkValue);
|
||||||
long? matchValueLong = NumberHelper.ConvertToInt64(this.Value);
|
long? matchValueLong = NumberHelper.ConvertToInt64(Value);
|
||||||
if (checkValueLong != null && matchValueLong != null)
|
if (checkValueLong != null && matchValueLong != null)
|
||||||
return checkValueLong < matchValueLong;
|
return checkValueLong < matchValueLong;
|
||||||
|
|
||||||
// Check Double values
|
// Check Double values
|
||||||
double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue);
|
double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue);
|
||||||
double? matchValueDouble = NumberHelper.ConvertToDouble(this.Value);
|
double? matchValueDouble = NumberHelper.ConvertToDouble(Value);
|
||||||
if (checkValueDouble != null && matchValueDouble != null)
|
if (checkValueDouble != null && matchValueDouble != null)
|
||||||
return checkValueDouble < matchValueDouble;
|
return checkValueDouble < matchValueDouble;
|
||||||
}
|
}
|
||||||
@@ -286,26 +274,26 @@ namespace SabreTools.Core.Filter
|
|||||||
private bool MatchesLessThanOrEqual(DictionaryBase dictionaryBase)
|
private bool MatchesLessThanOrEqual(DictionaryBase dictionaryBase)
|
||||||
{
|
{
|
||||||
// If the key doesn't exist, we count it as null
|
// If the key doesn't exist, we count it as null
|
||||||
if (!dictionaryBase.ContainsKey(this.Key[1]))
|
if (!dictionaryBase.ContainsKey(Key[1]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If the value in the dictionary is null
|
// If the value in the dictionary is null
|
||||||
string? checkValue = dictionaryBase.ReadString(this.Key[1]);
|
string? checkValue = dictionaryBase.ReadString(Key[1]);
|
||||||
if (checkValue == null)
|
if (checkValue == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If we have both a potentially numeric check and value
|
// If we have both a potentially numeric check and value
|
||||||
if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(this.Value))
|
if (NumberHelper.IsNumeric(checkValue) && NumberHelper.IsNumeric(Value))
|
||||||
{
|
{
|
||||||
// Check Int64 values
|
// Check Int64 values
|
||||||
long? checkValueLong = NumberHelper.ConvertToInt64(checkValue);
|
long? checkValueLong = NumberHelper.ConvertToInt64(checkValue);
|
||||||
long? matchValueLong = NumberHelper.ConvertToInt64(this.Value);
|
long? matchValueLong = NumberHelper.ConvertToInt64(Value);
|
||||||
if (checkValueLong != null && matchValueLong != null)
|
if (checkValueLong != null && matchValueLong != null)
|
||||||
return checkValueLong <= matchValueLong;
|
return checkValueLong <= matchValueLong;
|
||||||
|
|
||||||
// Check Double values
|
// Check Double values
|
||||||
double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue);
|
double? checkValueDouble = NumberHelper.ConvertToDouble(checkValue);
|
||||||
double? matchValueDouble = NumberHelper.ConvertToDouble(this.Value);
|
double? matchValueDouble = NumberHelper.ConvertToDouble(Value);
|
||||||
if (checkValueDouble != null && matchValueDouble != null)
|
if (checkValueDouble != null && matchValueDouble != null)
|
||||||
return checkValueDouble <= matchValueDouble;
|
return checkValueDouble <= matchValueDouble;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,11 +13,7 @@ namespace SabreTools.Core.Filter
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set of filters to be run against an object
|
/// Set of filters to be run against an object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
#if NETFRAMEWORK || NETCOREAPP3_1
|
public FilterObject[] Filters { get; }
|
||||||
public FilterObject[] Filters { get; private set; }
|
|
||||||
#else
|
|
||||||
public FilterObject[] Filters { get; init; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public FilterRunner(FilterObject[]? filters)
|
public FilterRunner(FilterObject[]? filters)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ namespace SabreTools.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set of mapping strings
|
/// Set of mapping strings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] Mappings { get; private set; }
|
public string[] Mappings { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MappingAttribute(params string[] mappings)
|
public MappingAttribute(params string[] mappings)
|
||||||
{
|
{
|
||||||
this.Mappings = mappings;
|
Mappings = mappings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ namespace SabreTools.DatFiles
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Create an internal source and add to the dictionary
|
// Create an internal source and add to the dictionary
|
||||||
var source = new DatItems.Source { Index = indexId, Name = filename };
|
var source = new DatItems.Source(indexId, filename);
|
||||||
long sourceIndex = ItemsDB.AddSource(source);
|
long sourceIndex = ItemsDB.AddSource(source);
|
||||||
|
|
||||||
// Get the header from the metadata
|
// Get the header from the metadata
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ namespace SabreTools.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ResetDictionary()
|
public void ResetDictionary()
|
||||||
{
|
{
|
||||||
Items = [];
|
Items.Clear();
|
||||||
ItemsDB = new ItemDictionaryDB();
|
ItemsDB = new ItemDictionaryDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace SabreTools.DatFiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of items for each item type
|
/// Number of items for each item type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<ItemType, long> ItemCounts { get; private set; } = [];
|
public Dictionary<ItemType, long> ItemCounts { get; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of machines
|
/// Number of machines
|
||||||
@@ -46,12 +46,12 @@ namespace SabreTools.DatFiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of items for each hash type
|
/// Number of items for each hash type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<HashType, long> HashCounts { get; private set; } = [];
|
public Dictionary<HashType, long> HashCounts { get; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of items for each item status
|
/// Number of items for each item status
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<ItemStatus, long> StatusCounts { get; private set; } = [];
|
public Dictionary<ItemStatus, long> StatusCounts { get; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of items with the remove flag
|
/// Number of items with the remove flag
|
||||||
@@ -344,11 +344,11 @@ namespace SabreTools.DatFiles
|
|||||||
public void ResetStatistics()
|
public void ResetStatistics()
|
||||||
{
|
{
|
||||||
TotalCount = 0;
|
TotalCount = 0;
|
||||||
ItemCounts = [];
|
ItemCounts.Clear();
|
||||||
GameCount = 0;
|
GameCount = 0;
|
||||||
TotalSize = 0;
|
TotalSize = 0;
|
||||||
HashCounts = [];
|
HashCounts.Clear();
|
||||||
StatusCounts = [];
|
StatusCounts.Clear();
|
||||||
RemovedCount = 0;
|
RemovedCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,25 +11,37 @@ namespace SabreTools.DatFiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name or path of the Depot
|
/// Name or path of the Depot
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? Name { get; private set; }
|
public string? Name { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to use this Depot or not
|
/// Whether to use this Depot or not
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsActive { get; private set; }
|
public bool IsActive { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Depot byte-depth
|
/// Depot byte-depth
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Depth { get; private set; }
|
public int Depth { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="isActive">Set active state</param>
|
/// <param name="isActive">Set active state</param>
|
||||||
/// <param name="depth">Set depth between 0 and SHA-1's byte length</param>
|
/// <param name="depth">Set depth between 0 and SHA-1's byte length</param>
|
||||||
public DepotInformation(bool isActive = false, int depth = 4)
|
public DepotInformation(bool isActive, int depth = 4)
|
||||||
|
: this(null, isActive, depth)
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Set active state</param>
|
||||||
|
/// <param name="isActive">Set active state</param>
|
||||||
|
/// <param name="depth">Set depth between 0 and SHA-1's byte length</param>
|
||||||
|
public DepotInformation(string? name, bool isActive, int depth = 4)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
IsActive = isActive;
|
IsActive = isActive;
|
||||||
Depth = depth;
|
Depth = depth;
|
||||||
|
|
||||||
@@ -47,15 +59,7 @@ namespace SabreTools.DatFiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clone the current object
|
/// Clone the current object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public object Clone()
|
public object Clone() => new DepotInformation(Name, IsActive, Depth);
|
||||||
{
|
|
||||||
return new DepotInformation
|
|
||||||
{
|
|
||||||
Name = this.Name,
|
|
||||||
IsActive = this.IsActive,
|
|
||||||
Depth = this.Depth,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
// Prepare all internal variables
|
// Prepare all internal variables
|
||||||
var sr = new StreamReader(System.IO.File.OpenRead(filename), new UTF8Encoding(false));
|
var sr = new StreamReader(System.IO.File.OpenRead(filename), new UTF8Encoding(false));
|
||||||
var jtr = new JsonTextReader(sr);
|
var jtr = new JsonTextReader(sr);
|
||||||
var source = new Source { Index = indexId, Name = filename };
|
var source = new Source(indexId, filename);
|
||||||
long sourceIndex = ItemsDB.AddSource(source);
|
long sourceIndex = ItemsDB.AddSource(source);
|
||||||
|
|
||||||
// If we got a null reader, just return
|
// If we got a null reader, just return
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
ValidationFlags = XmlSchemaValidationFlags.None,
|
ValidationFlags = XmlSchemaValidationFlags.None,
|
||||||
ValidationType = ValidationType.None,
|
ValidationType = ValidationType.None,
|
||||||
});
|
});
|
||||||
var source = new Source { Index = indexId, Name = filename };
|
var source = new Source(indexId, filename);
|
||||||
long sourceIndex = ItemsDB.AddSource(source);
|
long sourceIndex = ItemsDB.AddSource(source);
|
||||||
|
|
||||||
// If we got a null reader, just return
|
// If we got a null reader, just return
|
||||||
|
|||||||
@@ -10,19 +10,19 @@ namespace SabreTools.DatItems
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Source index
|
/// Source index
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Index { get; set; }
|
public int Index { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Source name
|
/// Source name
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? Name { get; set; }
|
public string? Name { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Source ID, default 0</param>
|
/// <param name="id">Source ID</param>
|
||||||
/// <param name="source">Source name, default null</param>
|
/// <param name="source">Source name, optional</param>
|
||||||
public Source(int id = 0, string? source = null)
|
public Source(int id, string? source = null)
|
||||||
{
|
{
|
||||||
Index = id;
|
Index = id;
|
||||||
Name = source;
|
Name = source;
|
||||||
|
|||||||
@@ -115,22 +115,22 @@ namespace SabreTools.FileTypes
|
|||||||
/// <param name="getHashes">True if hashes for this file should be calculated (default), false otherwise</param>
|
/// <param name="getHashes">True if hashes for this file should be calculated (default), false otherwise</param>
|
||||||
public BaseFile(string filename, bool getHashes = true)
|
public BaseFile(string filename, bool getHashes = true)
|
||||||
{
|
{
|
||||||
this.Filename = filename;
|
Filename = filename;
|
||||||
|
|
||||||
if (getHashes)
|
if (getHashes)
|
||||||
{
|
{
|
||||||
BaseFile? temp = GetInfo(this.Filename, hashes: this.AvailableHashTypes);
|
BaseFile? temp = GetInfo(Filename, hashes: AvailableHashTypes);
|
||||||
if (temp != null)
|
if (temp != null)
|
||||||
{
|
{
|
||||||
this.Parent = temp.Parent;
|
Parent = temp.Parent;
|
||||||
this.Date = temp.Date;
|
Date = temp.Date;
|
||||||
this.CRC = temp.CRC;
|
CRC = temp.CRC;
|
||||||
this.MD5 = temp.MD5;
|
MD5 = temp.MD5;
|
||||||
this.SHA1 = temp.SHA1;
|
SHA1 = temp.SHA1;
|
||||||
this.SHA256 = temp.SHA256;
|
SHA256 = temp.SHA256;
|
||||||
this.SHA384 = temp.SHA384;
|
SHA384 = temp.SHA384;
|
||||||
this.SHA512 = temp.SHA512;
|
SHA512 = temp.SHA512;
|
||||||
this.SpamSum = temp.SpamSum;
|
SpamSum = temp.SpamSum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,22 +143,22 @@ namespace SabreTools.FileTypes
|
|||||||
/// <param name="getHashes">True if hashes for this file should be calculated (default), false otherwise</param>
|
/// <param name="getHashes">True if hashes for this file should be calculated (default), false otherwise</param>
|
||||||
public BaseFile(string filename, Stream stream, bool getHashes = true)
|
public BaseFile(string filename, Stream stream, bool getHashes = true)
|
||||||
{
|
{
|
||||||
this.Filename = filename;
|
Filename = filename;
|
||||||
|
|
||||||
if (getHashes)
|
if (getHashes)
|
||||||
{
|
{
|
||||||
BaseFile temp = GetInfo(stream, hashes: this.AvailableHashTypes);
|
BaseFile temp = GetInfo(stream, hashes: AvailableHashTypes);
|
||||||
if (temp != null)
|
if (temp != null)
|
||||||
{
|
{
|
||||||
this.Parent = temp.Parent;
|
Parent = temp.Parent;
|
||||||
this.Date = temp.Date;
|
Date = temp.Date;
|
||||||
this.CRC = temp.CRC;
|
CRC = temp.CRC;
|
||||||
this.MD5 = temp.MD5;
|
MD5 = temp.MD5;
|
||||||
this.SHA1 = temp.SHA1;
|
SHA1 = temp.SHA1;
|
||||||
this.SHA256 = temp.SHA256;
|
SHA256 = temp.SHA256;
|
||||||
this.SHA384 = temp.SHA384;
|
SHA384 = temp.SHA384;
|
||||||
this.SHA512 = temp.SHA512;
|
SHA512 = temp.SHA512;
|
||||||
this.SpamSum = temp.SpamSum;
|
SpamSum = temp.SpamSum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace SabreTools.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Flag specific to Folder to omit Machine name from output path
|
/// Flag specific to Folder to omit Machine name from output path
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly bool writeToParent = false;
|
private readonly bool _writeToParent = false;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ namespace SabreTools.FileTypes
|
|||||||
public Folder(bool writeToParent = false)
|
public Folder(bool writeToParent = false)
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
this.writeToParent = writeToParent;
|
_writeToParent = writeToParent;
|
||||||
logger = new Logger(this);
|
logger = new Logger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,17 +96,17 @@ namespace SabreTools.FileTypes
|
|||||||
public virtual bool CopyAll(string outDir)
|
public virtual bool CopyAll(string outDir)
|
||||||
{
|
{
|
||||||
// If we have an invalid filename
|
// If we have an invalid filename
|
||||||
if (this.Filename == null)
|
if (Filename == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Copy all files from the current folder to the output directory recursively
|
// Copy all files from the current folder to the output directory recursively
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Make sure the folders exist
|
// Make sure the folders exist
|
||||||
Directory.CreateDirectory(this.Filename);
|
Directory.CreateDirectory(Filename);
|
||||||
Directory.CreateDirectory(outDir);
|
Directory.CreateDirectory(outDir);
|
||||||
|
|
||||||
DirectoryCopy(this.Filename, outDir, true);
|
DirectoryCopy(Filename, outDir, true);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -167,18 +167,18 @@ namespace SabreTools.FileTypes
|
|||||||
string? realentry = null;
|
string? realentry = null;
|
||||||
|
|
||||||
// If we have an invalid filename
|
// If we have an invalid filename
|
||||||
if (this.Filename == null)
|
if (Filename == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Copy single file from the current folder to the output directory, if exists
|
// Copy single file from the current folder to the output directory, if exists
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Make sure the folders exist
|
// Make sure the folders exist
|
||||||
Directory.CreateDirectory(this.Filename);
|
Directory.CreateDirectory(Filename);
|
||||||
Directory.CreateDirectory(outDir);
|
Directory.CreateDirectory(outDir);
|
||||||
|
|
||||||
// Get all files from the input directory
|
// Get all files from the input directory
|
||||||
List<string> files = PathTool.GetFilesOrdered(this.Filename);
|
List<string> files = PathTool.GetFilesOrdered(Filename);
|
||||||
|
|
||||||
// Now sort through to find the first file that matches
|
// Now sort through to find the first file that matches
|
||||||
string? match = files.Where(s => s.EndsWith(entryName)).FirstOrDefault();
|
string? match = files.Where(s => s.EndsWith(entryName)).FirstOrDefault();
|
||||||
@@ -207,17 +207,17 @@ namespace SabreTools.FileTypes
|
|||||||
public virtual (Stream?, string?) GetEntryStream(string entryName)
|
public virtual (Stream?, string?) GetEntryStream(string entryName)
|
||||||
{
|
{
|
||||||
// If we have an invalid filename
|
// If we have an invalid filename
|
||||||
if (this.Filename == null)
|
if (Filename == null)
|
||||||
return (null, null);
|
return (null, null);
|
||||||
|
|
||||||
// Copy single file from the current folder to the output directory, if exists
|
// Copy single file from the current folder to the output directory, if exists
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Make sure the folders exist
|
// Make sure the folders exist
|
||||||
Directory.CreateDirectory(this.Filename);
|
Directory.CreateDirectory(Filename);
|
||||||
|
|
||||||
// Get all files from the input directory
|
// Get all files from the input directory
|
||||||
List<string> files = PathTool.GetFilesOrdered(this.Filename);
|
List<string> files = PathTool.GetFilesOrdered(Filename);
|
||||||
|
|
||||||
// Now sort through to find the first file that matches
|
// Now sort through to find the first file that matches
|
||||||
string? match = files.Where(s => s.EndsWith(entryName)).FirstOrDefault();
|
string? match = files.Where(s => s.EndsWith(entryName)).FirstOrDefault();
|
||||||
@@ -249,27 +249,27 @@ namespace SabreTools.FileTypes
|
|||||||
public virtual List<BaseFile>? GetChildren()
|
public virtual List<BaseFile>? GetChildren()
|
||||||
{
|
{
|
||||||
// If we have an invalid filename
|
// If we have an invalid filename
|
||||||
if (this.Filename == null)
|
if (Filename == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (_children == null || _children.Count == 0)
|
if (_children == null || _children.Count == 0)
|
||||||
{
|
{
|
||||||
_children = [];
|
_children = [];
|
||||||
#if NET20 || NET35
|
#if NET20 || NET35
|
||||||
foreach (string file in Directory.GetFiles(this.Filename, "*"))
|
foreach (string file in Directory.GetFiles(Filename, "*"))
|
||||||
#else
|
#else
|
||||||
foreach (string file in Directory.EnumerateFiles(this.Filename, "*", SearchOption.TopDirectoryOnly))
|
foreach (string file in Directory.EnumerateFiles(Filename, "*", SearchOption.TopDirectoryOnly))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
BaseFile? nf = GetInfo(file, hashes: this.AvailableHashTypes);
|
BaseFile? nf = GetInfo(file, hashes: AvailableHashTypes);
|
||||||
if (nf != null)
|
if (nf != null)
|
||||||
_children.Add(nf);
|
_children.Add(nf);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NET20 || NET35
|
#if NET20 || NET35
|
||||||
foreach (string dir in Directory.GetDirectories(this.Filename, "*"))
|
foreach (string dir in Directory.GetDirectories(Filename, "*"))
|
||||||
#else
|
#else
|
||||||
foreach (string dir in Directory.EnumerateDirectories(this.Filename, "*", SearchOption.TopDirectoryOnly))
|
foreach (string dir in Directory.EnumerateDirectories(Filename, "*", SearchOption.TopDirectoryOnly))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
Folder fl = new(dir);
|
Folder fl = new(dir);
|
||||||
@@ -287,7 +287,7 @@ namespace SabreTools.FileTypes
|
|||||||
/// <returns>List of empty folders in the folder</returns>
|
/// <returns>List of empty folders in the folder</returns>
|
||||||
public virtual List<string>? GetEmptyFolders()
|
public virtual List<string>? GetEmptyFolders()
|
||||||
{
|
{
|
||||||
return this.Filename.ListEmpty();
|
return Filename.ListEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -331,7 +331,7 @@ namespace SabreTools.FileTypes
|
|||||||
|
|
||||||
// Get the output folder name from the first rebuild rom
|
// Get the output folder name from the first rebuild rom
|
||||||
string fileName;
|
string fileName;
|
||||||
if (writeToParent)
|
if (_writeToParent)
|
||||||
fileName = Path.Combine(outDir, TextHelper.RemovePathUnsafeCharacters(baseFile.Filename) ?? string.Empty);
|
fileName = Path.Combine(outDir, TextHelper.RemovePathUnsafeCharacters(baseFile.Filename) ?? string.Empty);
|
||||||
else
|
else
|
||||||
#if NET20 || NET35
|
#if NET20 || NET35
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace SabreTools.Filtering
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of extras to apply
|
/// List of extras to apply
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ExtraIniItem> Items { get; set; } = [];
|
public List<ExtraIniItem> Items { get; } = [];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace SabreTools.Reports
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public List<DatStatistics> Statistics { get; set; }
|
public List<DatStatistics> Statistics { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new report from the filename
|
/// Create a new report from the filename
|
||||||
|
|||||||
@@ -45,13 +45,13 @@ namespace SabreTools.Test.DatItems
|
|||||||
var romA = new Rom();
|
var romA = new Rom();
|
||||||
romA.SetName("same-name");
|
romA.SetName("same-name");
|
||||||
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
romA.SetFieldValue<Source?>(DatItem.SourceKey, new Source { Index = 0 });
|
romA.SetFieldValue<Source?>(DatItem.SourceKey, new Source(0));
|
||||||
romA.CopyMachineInformation(machineA);
|
romA.CopyMachineInformation(machineA);
|
||||||
|
|
||||||
var romB = new Rom();
|
var romB = new Rom();
|
||||||
romB.SetName("same-name");
|
romB.SetName("same-name");
|
||||||
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
romB.SetFieldValue<Source?>(DatItem.SourceKey, new Source { Index = 1 });
|
romB.SetFieldValue<Source?>(DatItem.SourceKey, new Source(1));
|
||||||
romB.CopyMachineInformation(machineB);
|
romB.CopyMachineInformation(machineB);
|
||||||
|
|
||||||
var actual = romA.GetDuplicateStatus(romB);
|
var actual = romA.GetDuplicateStatus(romB);
|
||||||
@@ -70,13 +70,13 @@ namespace SabreTools.Test.DatItems
|
|||||||
var romA = new Rom();
|
var romA = new Rom();
|
||||||
romA.SetName("same-name");
|
romA.SetName("same-name");
|
||||||
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
romA.SetFieldValue<Source?>(DatItem.SourceKey, new Source { Index = 0 });
|
romA.SetFieldValue<Source?>(DatItem.SourceKey, new Source(0));
|
||||||
romA.CopyMachineInformation(machineA);
|
romA.CopyMachineInformation(machineA);
|
||||||
|
|
||||||
var romB = new Rom();
|
var romB = new Rom();
|
||||||
romB.SetName("same-name");
|
romB.SetName("same-name");
|
||||||
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
romB.SetFieldValue<Source?>(DatItem.SourceKey, new Source { Index = 1 });
|
romB.SetFieldValue<Source?>(DatItem.SourceKey, new Source(1));
|
||||||
romB.CopyMachineInformation(machineB);
|
romB.CopyMachineInformation(machineB);
|
||||||
|
|
||||||
var actual = romA.GetDuplicateStatus(romB);
|
var actual = romA.GetDuplicateStatus(romB);
|
||||||
@@ -95,13 +95,13 @@ namespace SabreTools.Test.DatItems
|
|||||||
var romA = new Rom();
|
var romA = new Rom();
|
||||||
romA.SetName("same-name");
|
romA.SetName("same-name");
|
||||||
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
romA.SetFieldValue<Source?>(DatItem.SourceKey, new Source { Index = 0 });
|
romA.SetFieldValue<Source?>(DatItem.SourceKey, new Source(0));
|
||||||
romA.CopyMachineInformation(machineA);
|
romA.CopyMachineInformation(machineA);
|
||||||
|
|
||||||
var romB = new Rom();
|
var romB = new Rom();
|
||||||
romB.SetName("same-name");
|
romB.SetName("same-name");
|
||||||
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
romB.SetFieldValue<Source?>(DatItem.SourceKey, new Source { Index = 0 });
|
romB.SetFieldValue<Source?>(DatItem.SourceKey, new Source(0));
|
||||||
romB.CopyMachineInformation(machineB);
|
romB.CopyMachineInformation(machineB);
|
||||||
|
|
||||||
var actual = romA.GetDuplicateStatus(romB);
|
var actual = romA.GetDuplicateStatus(romB);
|
||||||
@@ -120,13 +120,13 @@ namespace SabreTools.Test.DatItems
|
|||||||
var romA = new Rom();
|
var romA = new Rom();
|
||||||
romA.SetName("same-name");
|
romA.SetName("same-name");
|
||||||
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romA.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
romA.SetFieldValue<Source?>(DatItem.SourceKey, new Source { Index = 0 });
|
romA.SetFieldValue<Source?>(DatItem.SourceKey, new Source(0));
|
||||||
romA.CopyMachineInformation(machineA);
|
romA.CopyMachineInformation(machineA);
|
||||||
|
|
||||||
var romB = new Rom();
|
var romB = new Rom();
|
||||||
romB.SetName("same-name");
|
romB.SetName("same-name");
|
||||||
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
romB.SetFieldValue(Models.Metadata.Rom.CRCKey, "DEADBEEF");
|
||||||
romB.SetFieldValue<Source?>(DatItem.SourceKey, new Source { Index = 0 });
|
romB.SetFieldValue<Source?>(DatItem.SourceKey, new Source(0));
|
||||||
romB.CopyMachineInformation(machineB);
|
romB.CopyMachineInformation(machineB);
|
||||||
|
|
||||||
var actual = romA.GetDuplicateStatus(romB);
|
var actual = romA.GetDuplicateStatus(romB);
|
||||||
|
|||||||
Reference in New Issue
Block a user