diff --git a/SabreTools.Models/Internal/Machine.cs b/SabreTools.Models/Internal/Machine.cs new file mode 100644 index 00000000..5458757b --- /dev/null +++ b/SabreTools.Models/Internal/Machine.cs @@ -0,0 +1,282 @@ +using System.Collections.Generic; + +namespace SabreTools.Models.Internal +{ + /// + /// Format-agnostic representation of item data + /// + public class Machine : Dictionary + { + #region Keys + + /// Adjuster[] + public const string AdjusterKey = "adjuster"; + + /// Archive[] + public const string ArchiveKey = "archive"; + + /// BiosSet[] + public const string BiosSetKey = "biosset"; + + /// string + public const string BoardKey = "board"; + + /// string + public const string ButtonsKey = "buttons"; + + /// string, string[] + public const string CategoryKey = "category"; + + /// Chip[] + public const string ChipKey = "chip"; + + /// string + public const string CloneOfKey = "cloneof"; + + /// string + public const string CloneOfIdKey = "cloneofid"; + + /// string, string[] + public const string CommentKey = "comment"; + + /// string + public const string CompanyKey = "company"; + + /// Configuration[] + public const string ConfigurationKey = "configuration"; + + /// string + public const string ControlKey = "control"; + + /// string + public const string CountryKey = "country"; + + /// string + public const string DescriptionKey = "description"; + + /// DeviceRef[] + public const string DeviceRefKey = "device_ref"; + + /// DipSwitch[] + public const string DipSwitchKey = "dipswitch"; + + /// Disk[] + public const string DiskKey = "disk"; + + /// string + public const string DisplayCountKey = "displaycount"; + + /// Display[] + public const string DisplayKey = "display"; + + /// string + public const string DisplayTypeKey = "displaytype"; + + /// Driver, Driver[] + public const string DriverKey = "driver"; + + /// Dump[] + public const string DumpKey = "dump"; + + /// string + public const string DuplicateIDKey = "duplicateID"; + + /// string + public const string ExtraKey = "extra"; + + /// string + public const string FavoriteKey = "favorite"; + + /// string + public const string GenMSXIDKey = "genmsxid"; + + /// string + public const string HistoryKey = "history"; + + /// string + public const string IdKey = "id"; + + /// string + public const string Im1CRCKey = "im1CRC"; + + /// string + public const string Im2CRCKey = "im2CRC"; + + /// string + public const string ImageNumberKey = "imageNumber"; + + /// Info[] + public const string InfoKey = "info"; + + /// Input + public const string InputKey = "input"; + + /// (yes|no) "no" + public const string IsBiosKey = "isbios"; + + /// (yes|no) "no" + public const string IsDeviceKey = "isdevice"; + + /// (yes|no) "no" + public const string IsMechanicalKey = "ismechanical"; + + /// string + public const string LanguageKey = "language"; + + /// string + public const string LocationKey = "location"; + + /// string + public const string ManufacturerKey = "manufacturer"; + + /// Media[] + public const string MediaKey = "media"; + + /// string + public const string NotesKey = "notes"; + + /// Part[] + public const string PartKey = "part"; + + /// string + public const string PlayedCountKey = "playedcount"; + + /// string + public const string PlayedTimeKey = "playedtime"; + + /// string + public const string PlayersKey = "players"; + + /// Port[] + public const string PortKey = "port"; + + /// string + public const string PublisherKey = "publisher"; + + /// RamOption[] + public const string RamOptionKey = "ramoption"; + + /// string + public const string RebuildToKey = "rebuildto"; + + /// Release[] + public const string ReleaseKey = "release"; + + /// string + public const string ReleaseNumberKey = "releaseNumber"; + + /// Rom[] + public const string RomKey = "rom"; + + /// string + public const string RomOfKey = "romof"; + + /// string + public const string RotationKey = "rotation"; + + /// (yes|no) "no" + public const string RunnableKey = "runnable"; + + /// Sample[] + public const string SampleKey = "sample"; + + /// string + public const string SampleOfKey = "sampleof"; + + /// string + public const string SaveTypeKey = "saveType"; + + /// SharedFeat[] + public const string SharedFeatKey = "sharedfeat"; + + /// Slot[] + public const string SlotKey = "slot"; + + /// SoftwareList[] + public const string SoftwareListKey = "softwarelist"; + + /// Sound + public const string SoundKey = "sound"; + + /// string + public const string SourceFileKey = "sourcefile"; + + /// string + public const string SourceRomKey = "sourceRom"; + + /// string + public const string StatusKey = "status"; + + /// (yes|partial|no) "yes" + public const string SupportedKey = "supported"; + + /// string + public const string SystemKey = "system"; + + /// string + public const string TagsKey = "tags"; + + /// Trurip + public const string TruripKey = "trurip"; + + /// Video, Video[] + public const string VideoKey = "video"; + + /// string + public const string YearKey = "year"; + + #endregion + + #region Reading Helpers + + /// + /// Read a key as a bool, returning null on error + /// + public bool? ReadBool(string key) + { + if (string.IsNullOrWhiteSpace(key)) + return null; + if (!ContainsKey(key)) + return null; + return this[key] as bool?; + } + + /// + /// Read a key as a double, returning null on error + /// + public double? ReadDouble(string key) + { + if (string.IsNullOrWhiteSpace(key)) + return null; + if (!ContainsKey(key)) + return null; + return this[key] as double?; + } + + /// + /// Read a key as a long, returning null on error + /// + public long? ReadLong(string key) + { + if (string.IsNullOrWhiteSpace(key)) + return null; + if (!ContainsKey(key)) + return null; + return this[key] as long?; + } + + /// + /// Read a key as a string, returning null on error + /// + public string? ReadString(string key) + { + if (string.IsNullOrWhiteSpace(key)) + return null; + if (!ContainsKey(key)) + return null; + return this[key] as string; + } + + #endregion + } +} \ No newline at end of file diff --git a/SabreTools.Models/Internal/Rom.cs b/SabreTools.Models/Internal/Rom.cs index b3ae14c9..9dfd05e5 100644 --- a/SabreTools.Models/Internal/Rom.cs +++ b/SabreTools.Models/Internal/Rom.cs @@ -66,7 +66,7 @@ namespace SabreTools.Models.Internal public const string FileCountKey = "filecount"; /// bool; AttractMode.Row - public const string FileIsAvailable = "file_is_available"; + public const string FileIsAvailableKey = "file_is_available"; /// string public const string FlagsKey = "flags"; diff --git a/SabreTools.Serialization/Internal.AttractMode.cs b/SabreTools.Serialization/Internal.AttractMode.cs index 0b72475b..96a368b0 100644 --- a/SabreTools.Serialization/Internal.AttractMode.cs +++ b/SabreTools.Serialization/Internal.AttractMode.cs @@ -17,6 +17,7 @@ namespace SabreTools.Serialization [Models.Internal.Rom.NameKey] = item.Title, [Models.Internal.Rom.AltRomnameKey] = item.AltRomname, [Models.Internal.Rom.AltTitleKey] = item.AltTitle, + [Models.Internal.Rom.FileIsAvailableKey] = item.FileIsAvailable, }; return rom; } @@ -35,6 +36,7 @@ namespace SabreTools.Serialization Title = item.ReadString(Models.Internal.Rom.NameKey), AltRomname = item.ReadString(Models.Internal.Rom.AltRomnameKey), AltTitle = item.ReadString(Models.Internal.Rom.AltTitleKey), + FileIsAvailable = item.ReadString(Models.Internal.Rom.FileIsAvailableKey), }; return row; }