mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Make items XML serializable
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
using SabreTools.Library.Filtering;
|
||||
using SabreTools.Library.Tools;
|
||||
@@ -12,6 +13,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// Represents which DIP Switch(es) is associated with a set
|
||||
/// </summary>
|
||||
[JsonObject("dipswitch")]
|
||||
[XmlRoot("dipswitch")]
|
||||
public class DipSwitch : DatItem
|
||||
{
|
||||
#region Fields
|
||||
@@ -22,38 +24,53 @@ namespace SabreTools.Library.DatItems
|
||||
/// Name of the item
|
||||
/// </summary>
|
||||
[JsonProperty("name")]
|
||||
[XmlElement("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Tag associated with the dipswitch
|
||||
/// </summary>
|
||||
[JsonProperty("tag", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("tag")]
|
||||
public string Tag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Mask associated with the dipswitch
|
||||
/// </summary>
|
||||
[JsonProperty("mask", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("mask")]
|
||||
public string Mask { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Conditions associated with the dipswitch
|
||||
/// </summary>
|
||||
[JsonProperty("conditions", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("conditions")]
|
||||
public List<Condition> Conditions { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool ConditionsSpecified { get { return Conditions != null && Conditions.Count > 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// Locations associated with the dipswitch
|
||||
/// </summary>
|
||||
[JsonProperty("locations", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("locations")]
|
||||
public List<Location> Locations { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool LocationsSpecified { get { return Locations != null && Locations.Count > 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// Settings associated with the dipswitch
|
||||
/// </summary>
|
||||
[JsonProperty("values", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("values")]
|
||||
public List<Setting> Values { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool ValuesSpecified { get { return Values != null && Values.Count > 0; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region SoftwareList
|
||||
@@ -62,8 +79,20 @@ namespace SabreTools.Library.DatItems
|
||||
/// Original hardware part associated with the item
|
||||
/// </summary>
|
||||
[JsonProperty("part", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("part")]
|
||||
public Part Part { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool PartSpecified
|
||||
{
|
||||
get
|
||||
{
|
||||
return Part != null && Part != default
|
||||
&& ((Part.Name != null && Part.Name != default)
|
||||
|| (Part.Interface != null && Part.Interface != default));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion // Fields
|
||||
|
||||
Reference in New Issue
Block a user