mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-09-23 23:35:09 +00:00
Original is cloneable and comparable
This commit is contained in:
@@ -1,24 +1,50 @@
|
||||
using System;
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace SabreTools.Data.Models.Metadata
|
||||
{
|
||||
[JsonObject("original"), XmlRoot("original")]
|
||||
public class Original : DatItem
|
||||
public class Original : DatItem, ICloneable, IEquatable<Original>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public string? Content { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Keys
|
||||
|
||||
/// <remarks>bool</remarks>
|
||||
public const string ValueKey = "value";
|
||||
public bool? Value { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public Original() => ItemType = ItemType.Original;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public object Clone()
|
||||
{
|
||||
var obj = new Original();
|
||||
|
||||
obj.Content = Content;
|
||||
obj.Value = Value;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Original? other)
|
||||
{
|
||||
// Null never matches
|
||||
if (other is null)
|
||||
return false;
|
||||
|
||||
// Properties
|
||||
if ((Content is null) ^ (other.Content is null))
|
||||
return false;
|
||||
else if (Content is not null && !Content.Equals(other.Content, StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
if (Value != other.Value)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user