mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Remove nearly all explict fields
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using SabreTools.Core;
|
||||
using SabreTools.Core.Tools;
|
||||
|
||||
namespace SabreTools.DatItems.Formats
|
||||
{
|
||||
@@ -16,90 +12,26 @@ namespace SabreTools.DatItems.Formats
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Device type
|
||||
/// </summary>
|
||||
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("type")]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public DeviceType DeviceType
|
||||
[JsonIgnore]
|
||||
public bool InstancesSpecified
|
||||
{
|
||||
get => _internal.ReadString(Models.Metadata.Device.DeviceTypeKey).AsEnumValue<DeviceType>();
|
||||
set => _internal[Models.Metadata.Device.DeviceTypeKey] = value.AsStringValue<DeviceType>();
|
||||
get
|
||||
{
|
||||
var instances = GetFieldValue<Instance[]?>(Models.Metadata.Device.InstanceKey);
|
||||
return instances != null && instances.Length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool DeviceTypeSpecified { get { return DeviceType != DeviceType.NULL; } }
|
||||
|
||||
/// <summary>
|
||||
/// Device tag
|
||||
/// </summary>
|
||||
[JsonProperty("tag", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("tag")]
|
||||
public string? Tag
|
||||
public bool ExtensionsSpecified
|
||||
{
|
||||
get => _internal.ReadString(Models.Metadata.Device.TagKey);
|
||||
set => _internal[Models.Metadata.Device.TagKey] = value;
|
||||
get
|
||||
{
|
||||
var extensions = GetFieldValue<Extension[]?>(Models.Metadata.Device.ExtensionKey);
|
||||
return extensions != null && extensions.Length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fixed image format
|
||||
/// </summary>
|
||||
[JsonProperty("fixed_image", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("fixed_image")]
|
||||
public string? FixedImage
|
||||
{
|
||||
get => _internal.ReadString(Models.Metadata.Device.FixedImageKey);
|
||||
set => _internal[Models.Metadata.Device.FixedImageKey] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the devices is mandatory
|
||||
/// </summary>
|
||||
/// <remarks>Only value used seems to be 1. Used like bool, but actually int</remarks>
|
||||
[JsonProperty("mandatory", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("mandatory")]
|
||||
public long? Mandatory
|
||||
{
|
||||
get => _internal.ReadLong(Models.Metadata.Device.MandatoryKey);
|
||||
set => _internal[Models.Metadata.Device.MandatoryKey] = value;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool MandatorySpecified { get { return Mandatory != null; } }
|
||||
|
||||
/// <summary>
|
||||
/// Device interface
|
||||
/// </summary>
|
||||
[JsonProperty("interface", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("interface")]
|
||||
public string? Interface
|
||||
{
|
||||
get => _internal.ReadString(Models.Metadata.Device.InterfaceKey);
|
||||
set => _internal[Models.Metadata.Device.InterfaceKey] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Device instances
|
||||
/// </summary>
|
||||
[JsonProperty("instances", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("instances")]
|
||||
public List<Instance>? Instances
|
||||
{
|
||||
get => _internal.Read<Instance[]>(Models.Metadata.Device.InstanceKey)?.ToList();
|
||||
set => _internal[Models.Metadata.Device.InstanceKey] = value?.ToArray();
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool InstancesSpecified { get { return Instances != null && Instances.Count > 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// Device extensions
|
||||
/// </summary>
|
||||
[JsonProperty("extensions", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("extensions")]
|
||||
public List<Extension>? Extensions
|
||||
{
|
||||
get => _internal.Read<Extension[]>(Models.Metadata.Device.ExtensionKey)?.ToList();
|
||||
set => _internal[Models.Metadata.Device.ExtensionKey] = value?.ToArray();
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool ExtensionsSpecified { get { return Extensions != null && Extensions.Count > 0; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
Reference in New Issue
Block a user