mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-04-05 22:01:33 +00:00
Reduce enum overhead in metadata
This commit is contained in:
@@ -1575,5 +1575,568 @@ namespace SabreTools.Data.Extensions.Test
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region String to Enum
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("cpu", ChipType.CPU)]
|
||||
[InlineData("audio", ChipType.Audio)]
|
||||
public void AsChipTypeTest(string? field, ChipType? expected)
|
||||
{
|
||||
ChipType? actual = field.AsChipType();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("joy", ControlType.Joy)]
|
||||
[InlineData("stick", ControlType.Stick)]
|
||||
[InlineData("paddle", ControlType.Paddle)]
|
||||
[InlineData("pedal", ControlType.Pedal)]
|
||||
[InlineData("lightgun", ControlType.Lightgun)]
|
||||
[InlineData("positional", ControlType.Positional)]
|
||||
[InlineData("dial", ControlType.Dial)]
|
||||
[InlineData("trackball", ControlType.Trackball)]
|
||||
[InlineData("mouse", ControlType.Mouse)]
|
||||
[InlineData("only_buttons", ControlType.OnlyButtons)]
|
||||
[InlineData("keypad", ControlType.Keypad)]
|
||||
[InlineData("keyboard", ControlType.Keyboard)]
|
||||
[InlineData("mahjong", ControlType.Mahjong)]
|
||||
[InlineData("hanafuda", ControlType.Hanafuda)]
|
||||
[InlineData("gambling", ControlType.Gambling)]
|
||||
public void AsControlTypeTest(string? field, ControlType? expected)
|
||||
{
|
||||
ControlType? actual = field.AsControlType();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("unknown", DeviceType.Unknown)]
|
||||
[InlineData("cartridge", DeviceType.Cartridge)]
|
||||
[InlineData("floppydisk", DeviceType.FloppyDisk)]
|
||||
[InlineData("harddisk", DeviceType.HardDisk)]
|
||||
[InlineData("cylinder", DeviceType.Cylinder)]
|
||||
[InlineData("cassette", DeviceType.Cassette)]
|
||||
[InlineData("punchcard", DeviceType.PunchCard)]
|
||||
[InlineData("punchtape", DeviceType.PunchTape)]
|
||||
[InlineData("printout", DeviceType.Printout)]
|
||||
[InlineData("serial", DeviceType.Serial)]
|
||||
[InlineData("parallel", DeviceType.Parallel)]
|
||||
[InlineData("snapshot", DeviceType.Snapshot)]
|
||||
[InlineData("quickload", DeviceType.QuickLoad)]
|
||||
[InlineData("memcard", DeviceType.MemCard)]
|
||||
[InlineData("cdrom", DeviceType.CDROM)]
|
||||
[InlineData("magtape", DeviceType.MagTape)]
|
||||
[InlineData("romimage", DeviceType.ROMImage)]
|
||||
[InlineData("midiin", DeviceType.MIDIIn)]
|
||||
[InlineData("midiout", DeviceType.MIDIOut)]
|
||||
[InlineData("picture", DeviceType.Picture)]
|
||||
[InlineData("vidfile", DeviceType.VidFile)]
|
||||
public void AsDeviceTypeTest(string? field, DeviceType? expected)
|
||||
{
|
||||
DeviceType? actual = field.AsDeviceType();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("raster", DisplayType.Raster)]
|
||||
[InlineData("vector", DisplayType.Vector)]
|
||||
[InlineData("lcd", DisplayType.LCD)]
|
||||
[InlineData("svg", DisplayType.SVG)]
|
||||
[InlineData("unknown", DisplayType.Unknown)]
|
||||
public void AsDisplayTypeTest(string? field, DisplayType? expected)
|
||||
{
|
||||
DisplayType? actual = field.AsDisplayType();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("big", Endianness.Big)]
|
||||
[InlineData("little", Endianness.Little)]
|
||||
public void AsEndiannessTest(string? field, Endianness? expected)
|
||||
{
|
||||
Endianness? actual = field.AsEndianness();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("unemulated", FeatureStatus.Unemulated)]
|
||||
[InlineData("imperfect", FeatureStatus.Imperfect)]
|
||||
public void AsFeatureStatusTest(string? field, FeatureStatus? expected)
|
||||
{
|
||||
FeatureStatus? actual = field.AsFeatureStatus();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("protection", FeatureType.Protection)]
|
||||
[InlineData("palette", FeatureType.Palette)]
|
||||
[InlineData("graphics", FeatureType.Graphics)]
|
||||
[InlineData("sound", FeatureType.Sound)]
|
||||
[InlineData("controls", FeatureType.Controls)]
|
||||
[InlineData("keyboard", FeatureType.Keyboard)]
|
||||
[InlineData("mouse", FeatureType.Mouse)]
|
||||
[InlineData("microphone", FeatureType.Microphone)]
|
||||
[InlineData("camera", FeatureType.Camera)]
|
||||
[InlineData("disk", FeatureType.Disk)]
|
||||
[InlineData("printer", FeatureType.Printer)]
|
||||
[InlineData("lan", FeatureType.Lan)]
|
||||
[InlineData("wan", FeatureType.Wan)]
|
||||
[InlineData("timing", FeatureType.Timing)]
|
||||
public void AsFeatureTypeTest(string? field, FeatureType? expected)
|
||||
{
|
||||
FeatureType? actual = field.AsFeatureType();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("none", ItemStatus.None)]
|
||||
[InlineData("no", ItemStatus.None)]
|
||||
[InlineData("good", ItemStatus.Good)]
|
||||
[InlineData("baddump", ItemStatus.BadDump)]
|
||||
[InlineData("nodump", ItemStatus.Nodump)]
|
||||
[InlineData("yes", ItemStatus.Nodump)]
|
||||
[InlineData("verified", ItemStatus.Verified)]
|
||||
public void AsItemStatusTest(string? field, ItemStatus? expected)
|
||||
{
|
||||
ItemStatus? actual = field.AsItemStatus();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("load16_byte", LoadFlag.Load16Byte)]
|
||||
[InlineData("load16_word", LoadFlag.Load16Word)]
|
||||
[InlineData("load16_word_swap", LoadFlag.Load16WordSwap)]
|
||||
[InlineData("load32_byte", LoadFlag.Load32Byte)]
|
||||
[InlineData("load32_word", LoadFlag.Load32Word)]
|
||||
[InlineData("load32_word_swap", LoadFlag.Load32WordSwap)]
|
||||
[InlineData("load32_dword", LoadFlag.Load32DWord)]
|
||||
[InlineData("load64_word", LoadFlag.Load64Word)]
|
||||
[InlineData("load64_word_swap", LoadFlag.Load64WordSwap)]
|
||||
[InlineData("reload", LoadFlag.Reload)]
|
||||
[InlineData("fill", LoadFlag.Fill)]
|
||||
[InlineData("continue", LoadFlag.Continue)]
|
||||
[InlineData("reload_plain", LoadFlag.ReloadPlain)]
|
||||
[InlineData("ignore", LoadFlag.Ignore)]
|
||||
public void AsLoadFlagTest(string? field, LoadFlag? expected)
|
||||
{
|
||||
LoadFlag? actual = field.AsLoadFlag();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, MergingFlag.None)]
|
||||
[InlineData("none", MergingFlag.None)]
|
||||
[InlineData("split", MergingFlag.Split)]
|
||||
[InlineData("merged", MergingFlag.Merged)]
|
||||
[InlineData("nonmerged", MergingFlag.NonMerged)]
|
||||
[InlineData("unmerged", MergingFlag.NonMerged)]
|
||||
[InlineData("fullmerged", MergingFlag.FullMerged)]
|
||||
[InlineData("device", MergingFlag.DeviceNonMerged)]
|
||||
[InlineData("devicenonmerged", MergingFlag.DeviceNonMerged)]
|
||||
[InlineData("deviceunmerged", MergingFlag.DeviceNonMerged)]
|
||||
[InlineData("full", MergingFlag.FullNonMerged)]
|
||||
[InlineData("fullnonmerged", MergingFlag.FullNonMerged)]
|
||||
[InlineData("fullunmerged", MergingFlag.FullNonMerged)]
|
||||
public void AsMergingFlagTest(string? field, MergingFlag expected)
|
||||
{
|
||||
MergingFlag actual = field.AsMergingFlag();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, NodumpFlag.None)]
|
||||
[InlineData("none", NodumpFlag.None)]
|
||||
[InlineData("obsolete", NodumpFlag.Obsolete)]
|
||||
[InlineData("required", NodumpFlag.Required)]
|
||||
[InlineData("ignore", NodumpFlag.Ignore)]
|
||||
public void AsNodumpFlagTest(string? field, NodumpFlag expected)
|
||||
{
|
||||
NodumpFlag actual = field.AsNodumpFlag();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("rom", OpenMSXSubType.Rom)]
|
||||
[InlineData("megarom", OpenMSXSubType.MegaRom)]
|
||||
[InlineData("sccpluscart", OpenMSXSubType.SCCPlusCart)]
|
||||
public void AsOpenMSXSubTypeTest(string? field, OpenMSXSubType? expected)
|
||||
{
|
||||
OpenMSXSubType? actual = field.AsOpenMSXSubType();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, PackingFlag.None)]
|
||||
[InlineData("none", PackingFlag.None)]
|
||||
[InlineData("yes", PackingFlag.Zip)]
|
||||
[InlineData("zip", PackingFlag.Zip)]
|
||||
[InlineData("no", PackingFlag.Unzip)]
|
||||
[InlineData("unzip", PackingFlag.Unzip)]
|
||||
[InlineData("partial", PackingFlag.Partial)]
|
||||
[InlineData("flat", PackingFlag.Flat)]
|
||||
[InlineData("fileonly", PackingFlag.FileOnly)]
|
||||
public void AsPackingFlagTest(string? field, PackingFlag expected)
|
||||
{
|
||||
PackingFlag actual = field.AsPackingFlag();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("eq", Relation.Equal)]
|
||||
[InlineData("ne", Relation.NotEqual)]
|
||||
[InlineData("gt", Relation.GreaterThan)]
|
||||
[InlineData("le", Relation.LessThanOrEqual)]
|
||||
[InlineData("lt", Relation.LessThan)]
|
||||
[InlineData("ge", Relation.GreaterThanOrEqual)]
|
||||
public void AsRelationTest(string? field, Relation? expected)
|
||||
{
|
||||
Relation? actual = field.AsRelation();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("no", Runnable.No)]
|
||||
[InlineData("partial", Runnable.Partial)]
|
||||
[InlineData("yes", Runnable.Yes)]
|
||||
public void AsRunnableTest(string? field, Runnable? expected)
|
||||
{
|
||||
Runnable? actual = field.AsRunnable();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("none", SoftwareListStatus.None)]
|
||||
[InlineData("original", SoftwareListStatus.Original)]
|
||||
[InlineData("compatible", SoftwareListStatus.Compatible)]
|
||||
public void AsSoftwareListStatusTest(string? field, SoftwareListStatus? expected)
|
||||
{
|
||||
SoftwareListStatus? actual = field.AsSoftwareListStatus();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("no", Supported.No)]
|
||||
[InlineData("unsupported", Supported.No)]
|
||||
[InlineData("partial", Supported.Partial)]
|
||||
[InlineData("yes", Supported.Yes)]
|
||||
[InlineData("supported", Supported.Yes)]
|
||||
public void AsSupportedTest(string? field, Supported? expected)
|
||||
{
|
||||
Supported? actual = field.AsSupported();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null)]
|
||||
[InlineData("good", SupportStatus.Good)]
|
||||
[InlineData("imperfect", SupportStatus.Imperfect)]
|
||||
[InlineData("preliminary", SupportStatus.Preliminary)]
|
||||
public void AsSupportStatusTest(string? field, SupportStatus? expected)
|
||||
{
|
||||
SupportStatus? actual = field.AsSupportStatus();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Enum to String
|
||||
|
||||
[Theory]
|
||||
[InlineData((ChipType)int.MaxValue, null)]
|
||||
[InlineData(ChipType.CPU, "cpu")]
|
||||
[InlineData(ChipType.Audio, "audio")]
|
||||
public void FromChipTypeTest(ChipType field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((ControlType)int.MaxValue, null)]
|
||||
[InlineData(ControlType.Joy, "joy")]
|
||||
[InlineData(ControlType.Stick, "stick")]
|
||||
[InlineData(ControlType.Paddle, "paddle")]
|
||||
[InlineData(ControlType.Pedal, "pedal")]
|
||||
[InlineData(ControlType.Lightgun, "lightgun")]
|
||||
[InlineData(ControlType.Positional, "positional")]
|
||||
[InlineData(ControlType.Dial, "dial")]
|
||||
[InlineData(ControlType.Trackball, "trackball")]
|
||||
[InlineData(ControlType.Mouse, "mouse")]
|
||||
[InlineData(ControlType.OnlyButtons, "only_buttons")]
|
||||
[InlineData(ControlType.Keypad, "keypad")]
|
||||
[InlineData(ControlType.Keyboard, "keyboard")]
|
||||
[InlineData(ControlType.Mahjong, "mahjong")]
|
||||
[InlineData(ControlType.Hanafuda, "hanafuda")]
|
||||
[InlineData(ControlType.Gambling, "gambling")]
|
||||
public void FromControlTypeTest(ControlType field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((DeviceType)int.MaxValue, null)]
|
||||
[InlineData(DeviceType.Unknown, "unknown")]
|
||||
[InlineData(DeviceType.Cartridge, "cartridge")]
|
||||
[InlineData(DeviceType.FloppyDisk, "floppydisk")]
|
||||
[InlineData(DeviceType.HardDisk, "harddisk")]
|
||||
[InlineData(DeviceType.Cylinder, "cylinder")]
|
||||
[InlineData(DeviceType.Cassette, "cassette")]
|
||||
[InlineData(DeviceType.PunchCard, "punchcard")]
|
||||
[InlineData(DeviceType.PunchTape, "punchtape")]
|
||||
[InlineData(DeviceType.Printout, "printout")]
|
||||
[InlineData(DeviceType.Serial, "serial")]
|
||||
[InlineData(DeviceType.Parallel, "parallel")]
|
||||
[InlineData(DeviceType.Snapshot, "snapshot")]
|
||||
[InlineData(DeviceType.QuickLoad, "quickload")]
|
||||
[InlineData(DeviceType.MemCard, "memcard")]
|
||||
[InlineData(DeviceType.CDROM, "cdrom")]
|
||||
[InlineData(DeviceType.MagTape, "magtape")]
|
||||
[InlineData(DeviceType.ROMImage, "romimage")]
|
||||
[InlineData(DeviceType.MIDIIn, "midiin")]
|
||||
[InlineData(DeviceType.MIDIOut, "midiout")]
|
||||
[InlineData(DeviceType.Picture, "picture")]
|
||||
[InlineData(DeviceType.VidFile, "vidfile")]
|
||||
public void FromDeviceTypeTest(DeviceType field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((DisplayType)int.MaxValue, null)]
|
||||
[InlineData(DisplayType.Raster, "raster")]
|
||||
[InlineData(DisplayType.Vector, "vector")]
|
||||
[InlineData(DisplayType.LCD, "lcd")]
|
||||
[InlineData(DisplayType.SVG, "svg")]
|
||||
[InlineData(DisplayType.Unknown, "unknown")]
|
||||
public void FromDisplayTypeTest(DisplayType field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((Endianness)int.MaxValue, null)]
|
||||
[InlineData(Endianness.Big, "big")]
|
||||
[InlineData(Endianness.Little, "little")]
|
||||
public void FromEndiannessTest(Endianness field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((FeatureStatus)int.MaxValue, null)]
|
||||
[InlineData(FeatureStatus.Unemulated, "unemulated")]
|
||||
[InlineData(FeatureStatus.Imperfect, "imperfect")]
|
||||
public void FromFeatureStatusTest(FeatureStatus field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((FeatureType)int.MaxValue, null)]
|
||||
[InlineData(FeatureType.Protection, "protection")]
|
||||
[InlineData(FeatureType.Palette, "palette")]
|
||||
[InlineData(FeatureType.Graphics, "graphics")]
|
||||
[InlineData(FeatureType.Sound, "sound")]
|
||||
[InlineData(FeatureType.Controls, "controls")]
|
||||
[InlineData(FeatureType.Keyboard, "keyboard")]
|
||||
[InlineData(FeatureType.Mouse, "mouse")]
|
||||
[InlineData(FeatureType.Microphone, "microphone")]
|
||||
[InlineData(FeatureType.Camera, "camera")]
|
||||
[InlineData(FeatureType.Disk, "disk")]
|
||||
[InlineData(FeatureType.Printer, "printer")]
|
||||
[InlineData(FeatureType.Lan, "lan")]
|
||||
[InlineData(FeatureType.Wan, "wan")]
|
||||
[InlineData(FeatureType.Timing, "timing")]
|
||||
public void FromFeatureTypeTest(FeatureType field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((ItemStatus)int.MaxValue, true, null)]
|
||||
[InlineData((ItemStatus)int.MaxValue, false, null)]
|
||||
[InlineData(ItemStatus.None, true, "no")]
|
||||
[InlineData(ItemStatus.None, false, "none")]
|
||||
[InlineData(ItemStatus.Good, true, "good")]
|
||||
[InlineData(ItemStatus.Good, false, "good")]
|
||||
[InlineData(ItemStatus.BadDump, true, "baddump")]
|
||||
[InlineData(ItemStatus.BadDump, false, "baddump")]
|
||||
[InlineData(ItemStatus.Nodump, true, "yes")]
|
||||
[InlineData(ItemStatus.Nodump, false, "nodump")]
|
||||
[InlineData(ItemStatus.Verified, true, "verified")]
|
||||
[InlineData(ItemStatus.Verified, false, "verified")]
|
||||
public void FromItemStatusTest(ItemStatus field, bool useSecond, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue(useSecond);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((LoadFlag)int.MaxValue, null)]
|
||||
[InlineData(LoadFlag.Load16Byte, "load16_byte")]
|
||||
[InlineData(LoadFlag.Load16Word, "load16_word")]
|
||||
[InlineData(LoadFlag.Load16WordSwap, "load16_word_swap")]
|
||||
[InlineData(LoadFlag.Load32Byte, "load32_byte")]
|
||||
[InlineData(LoadFlag.Load32Word, "load32_word")]
|
||||
[InlineData(LoadFlag.Load32WordSwap, "load32_word_swap")]
|
||||
[InlineData(LoadFlag.Load32DWord, "load32_dword")]
|
||||
[InlineData(LoadFlag.Load64Word, "load64_word")]
|
||||
[InlineData(LoadFlag.Load64WordSwap, "load64_word_swap")]
|
||||
[InlineData(LoadFlag.Reload, "reload")]
|
||||
[InlineData(LoadFlag.Fill, "fill")]
|
||||
[InlineData(LoadFlag.Continue, "continue")]
|
||||
[InlineData(LoadFlag.ReloadPlain, "reload_plain")]
|
||||
[InlineData(LoadFlag.Ignore, "ignore")]
|
||||
public void FromLoadFlagTest(LoadFlag field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(MergingFlag.None, true, "none")]
|
||||
[InlineData(MergingFlag.None, false, "none")]
|
||||
[InlineData(MergingFlag.Split, true, "split")]
|
||||
[InlineData(MergingFlag.Split, false, "split")]
|
||||
[InlineData(MergingFlag.Merged, true, "merged")]
|
||||
[InlineData(MergingFlag.Merged, false, "merged")]
|
||||
[InlineData(MergingFlag.NonMerged, true, "unmerged")]
|
||||
[InlineData(MergingFlag.NonMerged, false, "nonmerged")]
|
||||
[InlineData(MergingFlag.FullMerged, true, "fullmerged")]
|
||||
[InlineData(MergingFlag.FullMerged, false, "fullmerged")]
|
||||
[InlineData(MergingFlag.DeviceNonMerged, true, "devicenonmerged")]
|
||||
[InlineData(MergingFlag.DeviceNonMerged, false, "device")]
|
||||
[InlineData(MergingFlag.FullNonMerged, true, "fullnonmerged")]
|
||||
[InlineData(MergingFlag.FullNonMerged, false, "full")]
|
||||
public void FromMergingFlagTest(MergingFlag field, bool useSecond, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue(useSecond);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(NodumpFlag.None, "none")]
|
||||
[InlineData(NodumpFlag.Obsolete, "obsolete")]
|
||||
[InlineData(NodumpFlag.Required, "required")]
|
||||
[InlineData(NodumpFlag.Ignore, "ignore")]
|
||||
public void FromNodumpFlagTest(NodumpFlag field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((OpenMSXSubType)int.MaxValue, null)]
|
||||
[InlineData(OpenMSXSubType.Rom, "rom")]
|
||||
[InlineData(OpenMSXSubType.MegaRom, "megarom")]
|
||||
[InlineData(OpenMSXSubType.SCCPlusCart, "sccpluscart")]
|
||||
public void FromOpenMSXSubTypeTest(OpenMSXSubType field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(PackingFlag.None, true, "none")]
|
||||
[InlineData(PackingFlag.None, false, "none")]
|
||||
[InlineData(PackingFlag.Zip, true, "yes")]
|
||||
[InlineData(PackingFlag.Zip, false, "zip")]
|
||||
[InlineData(PackingFlag.Unzip, true, "no")]
|
||||
[InlineData(PackingFlag.Unzip, false, "unzip")]
|
||||
[InlineData(PackingFlag.Partial, true, "partial")]
|
||||
[InlineData(PackingFlag.Partial, false, "partial")]
|
||||
[InlineData(PackingFlag.Flat, true, "flat")]
|
||||
[InlineData(PackingFlag.Flat, false, "flat")]
|
||||
[InlineData(PackingFlag.FileOnly, true, "fileonly")]
|
||||
[InlineData(PackingFlag.FileOnly, false, "fileonly")]
|
||||
public void FromPackingFlagTest(PackingFlag field, bool useSecond, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue(useSecond);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((Relation)int.MaxValue, null)]
|
||||
[InlineData(Relation.Equal, "eq")]
|
||||
[InlineData(Relation.NotEqual, "ne")]
|
||||
[InlineData(Relation.GreaterThan, "gt")]
|
||||
[InlineData(Relation.LessThanOrEqual, "le")]
|
||||
[InlineData(Relation.LessThan, "lt")]
|
||||
[InlineData(Relation.GreaterThanOrEqual, "ge")]
|
||||
public void FromRelationTest(Relation field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((Runnable)int.MaxValue, null)]
|
||||
[InlineData(Runnable.No, "no")]
|
||||
[InlineData(Runnable.Partial, "partial")]
|
||||
[InlineData(Runnable.Yes, "yes")]
|
||||
public void FromRunnableTest(Runnable field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((SoftwareListStatus)int.MaxValue, null)]
|
||||
[InlineData(SoftwareListStatus.None, "none")]
|
||||
[InlineData(SoftwareListStatus.Original, "original")]
|
||||
[InlineData(SoftwareListStatus.Compatible, "compatible")]
|
||||
public void FromSoftwareListStatusTest(SoftwareListStatus field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((Supported)int.MaxValue, true, null)]
|
||||
[InlineData((Supported)int.MaxValue, false, null)]
|
||||
[InlineData(Supported.No, true, "unsupported")]
|
||||
[InlineData(Supported.No, false, "no")]
|
||||
[InlineData(Supported.Partial, true, "partial")]
|
||||
[InlineData(Supported.Partial, false, "partial")]
|
||||
[InlineData(Supported.Yes, true, "supported")]
|
||||
[InlineData(Supported.Yes, false, "yes")]
|
||||
public void FromSupportedTest(Supported field, bool useSecond, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue(useSecond);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData((SupportStatus)int.MaxValue, null)]
|
||||
[InlineData(SupportStatus.Good, "good")]
|
||||
[InlineData(SupportStatus.Imperfect, "imperfect")]
|
||||
[InlineData(SupportStatus.Preliminary, "preliminary")]
|
||||
public void FromSupportStatusTest(SupportStatus field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -859,5 +859,722 @@ namespace SabreTools.Data.Extensions
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region String to Enum
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static ChipType? AsChipType(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"cpu" => ChipType.CPU,
|
||||
"audio" => ChipType.Audio,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static ControlType? AsControlType(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"joy" => ControlType.Joy,
|
||||
"stick" => ControlType.Stick,
|
||||
"paddle" => ControlType.Paddle,
|
||||
"pedal" => ControlType.Pedal,
|
||||
"lightgun" => ControlType.Lightgun,
|
||||
"positional" => ControlType.Positional,
|
||||
"dial" => ControlType.Dial,
|
||||
"trackball" => ControlType.Trackball,
|
||||
"mouse" => ControlType.Mouse,
|
||||
"only_buttons" => ControlType.OnlyButtons,
|
||||
"keypad" => ControlType.Keypad,
|
||||
"keyboard" => ControlType.Keyboard,
|
||||
"mahjong" => ControlType.Mahjong,
|
||||
"hanafuda" => ControlType.Hanafuda,
|
||||
"gambling" => ControlType.Gambling,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static DeviceType? AsDeviceType(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"unknown" => DeviceType.Unknown,
|
||||
"cartridge" => DeviceType.Cartridge,
|
||||
"floppydisk" => DeviceType.FloppyDisk,
|
||||
"harddisk" => DeviceType.HardDisk,
|
||||
"cylinder" => DeviceType.Cylinder,
|
||||
"cassette" => DeviceType.Cassette,
|
||||
"punchcard" => DeviceType.PunchCard,
|
||||
"punchtape" => DeviceType.PunchTape,
|
||||
"printout" => DeviceType.Printout,
|
||||
"serial" => DeviceType.Serial,
|
||||
"parallel" => DeviceType.Parallel,
|
||||
"snapshot" => DeviceType.Snapshot,
|
||||
"quickload" => DeviceType.QuickLoad,
|
||||
"memcard" => DeviceType.MemCard,
|
||||
"cdrom" => DeviceType.CDROM,
|
||||
"magtape" => DeviceType.MagTape,
|
||||
"romimage" => DeviceType.ROMImage,
|
||||
"midiin" => DeviceType.MIDIIn,
|
||||
"midiout" => DeviceType.MIDIOut,
|
||||
"picture" => DeviceType.Picture,
|
||||
"vidfile" => DeviceType.VidFile,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static DisplayType? AsDisplayType(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"raster" => DisplayType.Raster,
|
||||
"vector" => DisplayType.Vector,
|
||||
"lcd" => DisplayType.LCD,
|
||||
"svg" => DisplayType.SVG,
|
||||
"unknown" => DisplayType.Unknown,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static Endianness? AsEndianness(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"big" => Endianness.Big,
|
||||
"little" => Endianness.Little,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static FeatureStatus? AsFeatureStatus(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"unemulated" => FeatureStatus.Unemulated,
|
||||
"imperfect" => FeatureStatus.Imperfect,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static FeatureType? AsFeatureType(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"protection" => FeatureType.Protection,
|
||||
"palette" => FeatureType.Palette,
|
||||
"graphics" => FeatureType.Graphics,
|
||||
"sound" => FeatureType.Sound,
|
||||
"controls" => FeatureType.Controls,
|
||||
"keyboard" => FeatureType.Keyboard,
|
||||
"mouse" => FeatureType.Mouse,
|
||||
"microphone" => FeatureType.Microphone,
|
||||
"camera" => FeatureType.Camera,
|
||||
"disk" => FeatureType.Disk,
|
||||
"printer" => FeatureType.Printer,
|
||||
"lan" => FeatureType.Lan,
|
||||
"wan" => FeatureType.Wan,
|
||||
"timing" => FeatureType.Timing,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static ItemStatus? AsItemStatus(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"none" or "no" => ItemStatus.None,
|
||||
"good" => ItemStatus.Good,
|
||||
"baddump" => ItemStatus.BadDump,
|
||||
"nodump" or "yes" => ItemStatus.Nodump,
|
||||
"verified" => ItemStatus.Verified,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static LoadFlag? AsLoadFlag(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"load16_byte" => LoadFlag.Load16Byte,
|
||||
"load16_word" => LoadFlag.Load16Word,
|
||||
"load16_word_swap" => LoadFlag.Load16WordSwap,
|
||||
"load32_byte" => LoadFlag.Load32Byte,
|
||||
"load32_word" => LoadFlag.Load32Word,
|
||||
"load32_word_swap" => LoadFlag.Load32WordSwap,
|
||||
"load32_dword" => LoadFlag.Load32DWord,
|
||||
"load64_word" => LoadFlag.Load64Word,
|
||||
"load64_word_swap" => LoadFlag.Load64WordSwap,
|
||||
"reload" => LoadFlag.Reload,
|
||||
"fill" => LoadFlag.Fill,
|
||||
"continue" => LoadFlag.Continue,
|
||||
"reload_plain" => LoadFlag.ReloadPlain,
|
||||
"ignore" => LoadFlag.Ignore,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static MergingFlag AsMergingFlag(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"none" => MergingFlag.None,
|
||||
"split" => MergingFlag.Split,
|
||||
"merged" => MergingFlag.Merged,
|
||||
"nonmerged" or "unmerged" => MergingFlag.NonMerged,
|
||||
"fullmerged" => MergingFlag.FullMerged,
|
||||
"device" or "deviceunmerged" or "devicenonmerged" => MergingFlag.DeviceNonMerged,
|
||||
"full" or "fullunmerged" or "fullnonmerged" => MergingFlag.FullNonMerged,
|
||||
_ => MergingFlag.None,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static NodumpFlag AsNodumpFlag(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"none" => NodumpFlag.None,
|
||||
"obsolete" => NodumpFlag.Obsolete,
|
||||
"required" => NodumpFlag.Required,
|
||||
"ignore" => NodumpFlag.Ignore,
|
||||
_ => NodumpFlag.None,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static OpenMSXSubType? AsOpenMSXSubType(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"rom" => OpenMSXSubType.Rom,
|
||||
"megarom" => OpenMSXSubType.MegaRom,
|
||||
"sccpluscart" => OpenMSXSubType.SCCPlusCart,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static PackingFlag AsPackingFlag(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"none" => PackingFlag.None,
|
||||
"zip" or "yes" => PackingFlag.Zip,
|
||||
"unzip" or "no" => PackingFlag.Unzip,
|
||||
"partial" => PackingFlag.Partial,
|
||||
"flat" => PackingFlag.Flat,
|
||||
"fileonly" => PackingFlag.FileOnly,
|
||||
_ => PackingFlag.None,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static Relation? AsRelation(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"eq" => Relation.Equal,
|
||||
"ne" => Relation.NotEqual,
|
||||
"gt" => Relation.GreaterThan,
|
||||
"le" => Relation.LessThanOrEqual,
|
||||
"lt" => Relation.LessThan,
|
||||
"ge" => Relation.GreaterThanOrEqual,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static Runnable? AsRunnable(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"no" => Runnable.No,
|
||||
"partial" => Runnable.Partial,
|
||||
"yes" => Runnable.Yes,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static SoftwareListStatus? AsSoftwareListStatus(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"none" => SoftwareListStatus.None,
|
||||
"original" => SoftwareListStatus.Original,
|
||||
"compatible" => SoftwareListStatus.Compatible,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static Supported? AsSupported(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"no" or "unsupported" => Supported.No,
|
||||
"partial" => Supported.Partial,
|
||||
"yes" or "supported" => Supported.Yes,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, null on error</returns>
|
||||
public static SupportStatus? AsSupportStatus(this string? value)
|
||||
{
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"good" => SupportStatus.Good,
|
||||
"imperfect" => SupportStatus.Imperfect,
|
||||
"preliminary" => SupportStatus.Preliminary,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Enum to String
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this ChipType value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
ChipType.CPU => "cpu",
|
||||
ChipType.Audio => "audio",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this ControlType value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
ControlType.Joy => "joy",
|
||||
ControlType.Stick => "stick",
|
||||
ControlType.Paddle => "paddle",
|
||||
ControlType.Pedal => "pedal",
|
||||
ControlType.Lightgun => "lightgun",
|
||||
ControlType.Positional => "positional",
|
||||
ControlType.Dial => "dial",
|
||||
ControlType.Trackball => "trackball",
|
||||
ControlType.Mouse => "mouse",
|
||||
ControlType.OnlyButtons => "only_buttons",
|
||||
ControlType.Keypad => "keypad",
|
||||
ControlType.Keyboard => "keyboard",
|
||||
ControlType.Mahjong => "mahjong",
|
||||
ControlType.Hanafuda => "hanafuda",
|
||||
ControlType.Gambling => "gambling",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this DeviceType value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
DeviceType.Unknown => "unknown",
|
||||
DeviceType.Cartridge => "cartridge",
|
||||
DeviceType.FloppyDisk => "floppydisk",
|
||||
DeviceType.HardDisk => "harddisk",
|
||||
DeviceType.Cylinder => "cylinder",
|
||||
DeviceType.Cassette => "cassette",
|
||||
DeviceType.PunchCard => "punchcard",
|
||||
DeviceType.PunchTape => "punchtape",
|
||||
DeviceType.Printout => "printout",
|
||||
DeviceType.Serial => "serial",
|
||||
DeviceType.Parallel => "parallel",
|
||||
DeviceType.Snapshot => "snapshot",
|
||||
DeviceType.QuickLoad => "quickload",
|
||||
DeviceType.MemCard => "memcard",
|
||||
DeviceType.CDROM => "cdrom",
|
||||
DeviceType.MagTape => "magtape",
|
||||
DeviceType.ROMImage => "romimage",
|
||||
DeviceType.MIDIIn => "midiin",
|
||||
DeviceType.MIDIOut => "midiout",
|
||||
DeviceType.Picture => "picture",
|
||||
DeviceType.VidFile => "vidfile",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this DisplayType value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
DisplayType.Raster => "raster",
|
||||
DisplayType.Vector => "vector",
|
||||
DisplayType.LCD => "lcd",
|
||||
DisplayType.SVG => "svg",
|
||||
DisplayType.Unknown => "unknown",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this Endianness value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
Endianness.Big => "big",
|
||||
Endianness.Little => "little",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this FeatureStatus value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
FeatureStatus.Unemulated => "unemulated",
|
||||
FeatureStatus.Imperfect => "imperfect",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this FeatureType value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
FeatureType.Protection => "protection",
|
||||
FeatureType.Palette => "palette",
|
||||
FeatureType.Graphics => "graphics",
|
||||
FeatureType.Sound => "sound",
|
||||
FeatureType.Controls => "controls",
|
||||
FeatureType.Keyboard => "keyboard",
|
||||
FeatureType.Mouse => "mouse",
|
||||
FeatureType.Microphone => "microphone",
|
||||
FeatureType.Camera => "camera",
|
||||
FeatureType.Disk => "disk",
|
||||
FeatureType.Printer => "printer",
|
||||
FeatureType.Lan => "lan",
|
||||
FeatureType.Wan => "wan",
|
||||
FeatureType.Timing => "timing",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this ItemStatus value, bool useSecond = false)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
ItemStatus.None => useSecond ? "no" : "none",
|
||||
ItemStatus.Good => "good",
|
||||
ItemStatus.BadDump => "baddump",
|
||||
ItemStatus.Nodump => useSecond ? "yes" : "nodump",
|
||||
ItemStatus.Verified => "verified",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this LoadFlag value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
LoadFlag.Load16Byte => "load16_byte",
|
||||
LoadFlag.Load16Word => "load16_word",
|
||||
LoadFlag.Load16WordSwap => "load16_word_swap",
|
||||
LoadFlag.Load32Byte => "load32_byte",
|
||||
LoadFlag.Load32Word => "load32_word",
|
||||
LoadFlag.Load32WordSwap => "load32_word_swap",
|
||||
LoadFlag.Load32DWord => "load32_dword",
|
||||
LoadFlag.Load64Word => "load64_word",
|
||||
LoadFlag.Load64WordSwap => "load64_word_swap",
|
||||
LoadFlag.Reload => "reload",
|
||||
LoadFlag.Fill => "fill",
|
||||
LoadFlag.Continue => "continue",
|
||||
LoadFlag.ReloadPlain => "reload_plain",
|
||||
LoadFlag.Ignore => "ignore",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this MergingFlag value, bool useSecond = false)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
MergingFlag.None => "none",
|
||||
MergingFlag.Split => "split",
|
||||
MergingFlag.Merged => "merged",
|
||||
MergingFlag.NonMerged => useSecond ? "unmerged" : "nonmerged",
|
||||
MergingFlag.FullMerged => "fullmerged",
|
||||
MergingFlag.DeviceNonMerged => useSecond ? "devicenonmerged" : "device",
|
||||
MergingFlag.FullNonMerged => useSecond ? "fullnonmerged" : "full",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this NodumpFlag value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
NodumpFlag.None => "none",
|
||||
NodumpFlag.Obsolete => "obsolete",
|
||||
NodumpFlag.Required => "required",
|
||||
NodumpFlag.Ignore => "ignore",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this OpenMSXSubType value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
OpenMSXSubType.Rom => "rom",
|
||||
OpenMSXSubType.MegaRom => "megarom",
|
||||
OpenMSXSubType.SCCPlusCart => "sccpluscart",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this PackingFlag value, bool useSecond = false)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
PackingFlag.None => "none",
|
||||
PackingFlag.Zip => useSecond ? "yes" : "zip",
|
||||
PackingFlag.Unzip => useSecond ? "no" : "unzip",
|
||||
PackingFlag.Partial => "partial",
|
||||
PackingFlag.Flat => "flat",
|
||||
PackingFlag.FileOnly => "fileonly",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this Relation value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
Relation.Equal => "eq",
|
||||
Relation.NotEqual => "ne",
|
||||
Relation.GreaterThan => "gt",
|
||||
Relation.LessThanOrEqual => "le",
|
||||
Relation.LessThan => "lt",
|
||||
Relation.GreaterThanOrEqual => "ge",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this Runnable value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
Runnable.No => "no",
|
||||
Runnable.Partial => "partial",
|
||||
Runnable.Yes => "yes",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this SoftwareListStatus value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
SoftwareListStatus.None => "none",
|
||||
SoftwareListStatus.Original => "original",
|
||||
SoftwareListStatus.Compatible => "compatible",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this Supported value, bool useSecond = false)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
Supported.No => useSecond ? "unsupported" : "no",
|
||||
Supported.Partial => "partial",
|
||||
Supported.Yes => useSecond ? "supported" : "yes",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <returns>String value representing the input, null on error</returns>
|
||||
public static string? AsStringValue(this SupportStatus value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
SupportStatus.Good => "good",
|
||||
SupportStatus.Imperfect => "imperfect",
|
||||
SupportStatus.Preliminary => "preliminary",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
482
SabreTools.Data.Models/Metadata/Enums.cs
Normal file
482
SabreTools.Data.Models/Metadata/Enums.cs
Normal file
@@ -0,0 +1,482 @@
|
||||
namespace SabreTools.Data.Models.Metadata
|
||||
{
|
||||
/// <summary>
|
||||
/// Determine the chip type
|
||||
/// </summary>
|
||||
public enum ChipType
|
||||
{
|
||||
/// <summary>"cpu"</summary>
|
||||
CPU,
|
||||
|
||||
/// <summary>"audio"</summary>
|
||||
Audio,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the control type
|
||||
/// </summary>
|
||||
public enum ControlType
|
||||
{
|
||||
/// <summary>"joy"</summary>
|
||||
Joy,
|
||||
|
||||
/// <summary>"stick"</summary>
|
||||
Stick,
|
||||
|
||||
/// <summary>"paddle"</summary>
|
||||
Paddle,
|
||||
|
||||
/// <summary>"pedal"</summary>
|
||||
Pedal,
|
||||
|
||||
/// <summary>"lightgun"</summary>
|
||||
Lightgun,
|
||||
|
||||
/// <summary>"positional"</summary>
|
||||
Positional,
|
||||
|
||||
/// <summary>"dial"</summary>
|
||||
Dial,
|
||||
|
||||
/// <summary>"trackball"</summary>
|
||||
Trackball,
|
||||
|
||||
/// <summary>"mouse"</summary>
|
||||
Mouse,
|
||||
|
||||
/// <summary>"only_buttons"</summary>
|
||||
OnlyButtons,
|
||||
|
||||
/// <summary>"keypad"</summary>
|
||||
Keypad,
|
||||
|
||||
/// <summary>"keyboard"</summary>
|
||||
Keyboard,
|
||||
|
||||
/// <summary>"mahjong"</summary>
|
||||
Mahjong,
|
||||
|
||||
/// <summary>"hanafuda"</summary>
|
||||
Hanafuda,
|
||||
|
||||
/// <summary>"gambling"</summary>
|
||||
Gambling,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the device type
|
||||
/// </summary>
|
||||
public enum DeviceType
|
||||
{
|
||||
/// <summary>"unknown"</summary>
|
||||
Unknown,
|
||||
|
||||
/// <summary>"cartridge"</summary>
|
||||
Cartridge,
|
||||
|
||||
/// <summary>"floppydisk"</summary>
|
||||
FloppyDisk,
|
||||
|
||||
/// <summary>"harddisk"</summary>
|
||||
HardDisk,
|
||||
|
||||
/// <summary>"cylinder"</summary>
|
||||
Cylinder,
|
||||
|
||||
/// <summary>"cassette"</summary>
|
||||
Cassette,
|
||||
|
||||
/// <summary>"punchcard"</summary>
|
||||
PunchCard,
|
||||
|
||||
/// <summary>"punchtape"</summary>
|
||||
PunchTape,
|
||||
|
||||
/// <summary>"printout"</summary>
|
||||
Printout,
|
||||
|
||||
/// <summary>"serial"</summary>
|
||||
Serial,
|
||||
|
||||
/// <summary>"parallel"</summary>
|
||||
Parallel,
|
||||
|
||||
/// <summary>"snapshot"</summary>
|
||||
Snapshot,
|
||||
|
||||
/// <summary>"quickload"</summary>
|
||||
QuickLoad,
|
||||
|
||||
/// <summary>"memcard"</summary>
|
||||
MemCard,
|
||||
|
||||
/// <summary>"cdrom"</summary>
|
||||
CDROM,
|
||||
|
||||
/// <summary>"magtape"</summary>
|
||||
MagTape,
|
||||
|
||||
/// <summary>"romimage"</summary>
|
||||
ROMImage,
|
||||
|
||||
/// <summary>"midiin"</summary>
|
||||
MIDIIn,
|
||||
|
||||
/// <summary>"midiout"</summary>
|
||||
MIDIOut,
|
||||
|
||||
/// <summary>"picture"</summary>
|
||||
Picture,
|
||||
|
||||
/// <summary>"vidfile"</summary>
|
||||
VidFile,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the display type
|
||||
/// </summary>
|
||||
public enum DisplayType
|
||||
{
|
||||
/// <summary>"raster"</summary>
|
||||
Raster,
|
||||
|
||||
/// <summary>"vector"</summary>
|
||||
Vector,
|
||||
|
||||
/// <summary>"lcd"</summary>
|
||||
LCD,
|
||||
|
||||
/// <summary>"svg"</summary>
|
||||
SVG,
|
||||
|
||||
/// <summary>"unknown"</summary>
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the endianness
|
||||
/// </summary>
|
||||
public enum Endianness
|
||||
{
|
||||
/// <summary>"big"</summary>
|
||||
Big,
|
||||
|
||||
/// <summary>"little"</summary>
|
||||
Little,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the emulation status
|
||||
/// </summary>
|
||||
public enum FeatureStatus
|
||||
{
|
||||
/// <summary>"unemulated"</summary>
|
||||
Unemulated,
|
||||
|
||||
/// <summary>"imperfect"</summary>
|
||||
Imperfect,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the feature type
|
||||
/// </summary>
|
||||
public enum FeatureType
|
||||
{
|
||||
/// <summary>"protection"</summary>
|
||||
Protection,
|
||||
|
||||
/// <summary>"palette"</summary>
|
||||
Palette,
|
||||
|
||||
/// <summary>"graphics"</summary>
|
||||
Graphics,
|
||||
|
||||
/// <summary>"sound"</summary>
|
||||
Sound,
|
||||
|
||||
/// <summary>"controls"</summary>
|
||||
Controls,
|
||||
|
||||
/// <summary>"keyboard"</summary>
|
||||
Keyboard,
|
||||
|
||||
/// <summary>"mouse"</summary>
|
||||
Mouse,
|
||||
|
||||
/// <summary>"microphone"</summary>
|
||||
Microphone,
|
||||
|
||||
/// <summary>"camera"</summary>
|
||||
Camera,
|
||||
|
||||
/// <summary>"disk"</summary>
|
||||
Disk,
|
||||
|
||||
/// <summary>"printer"</summary>
|
||||
Printer,
|
||||
|
||||
/// <summary>"lan"</summary>
|
||||
Lan,
|
||||
|
||||
/// <summary>"wan"</summary>
|
||||
Wan,
|
||||
|
||||
/// <summary>"timing"</summary>
|
||||
Timing,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the status of the item
|
||||
/// </summary>
|
||||
public enum ItemStatus
|
||||
{
|
||||
/// <summary>"none", "no"</summary>
|
||||
None,
|
||||
|
||||
/// <summary>"good"</summary>
|
||||
Good,
|
||||
|
||||
/// <summary>"baddump"</summary>
|
||||
BadDump,
|
||||
|
||||
/// <summary>"nodump", "yes"</summary>
|
||||
Nodump,
|
||||
|
||||
/// <summary>"verified"</summary>
|
||||
Verified,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the loadflag value
|
||||
/// </summary>
|
||||
public enum LoadFlag
|
||||
{
|
||||
/// <summary>"load16_byte"</summary>
|
||||
Load16Byte,
|
||||
|
||||
/// <summary>"load16_word"</summary>
|
||||
Load16Word,
|
||||
|
||||
/// <summary>"load16_word_swap"</summary>
|
||||
Load16WordSwap,
|
||||
|
||||
/// <summary>"load32_byte"</summary>
|
||||
Load32Byte,
|
||||
|
||||
/// <summary>"load32_word"</summary>
|
||||
Load32Word,
|
||||
|
||||
/// <summary>"load32_word_swap"</summary>
|
||||
Load32WordSwap,
|
||||
|
||||
/// <summary>"load32_dword"</summary>
|
||||
Load32DWord,
|
||||
|
||||
/// <summary>"load64_word"</summary>
|
||||
Load64Word,
|
||||
|
||||
/// <summary>"load64_word_swap"</summary>
|
||||
Load64WordSwap,
|
||||
|
||||
/// <summary>"reload"</summary>
|
||||
Reload,
|
||||
|
||||
/// <summary>"fill"</summary>
|
||||
Fill,
|
||||
|
||||
/// <summary>"continue"</summary>
|
||||
Continue,
|
||||
|
||||
/// <summary>"reload_plain"</summary>
|
||||
ReloadPlain,
|
||||
|
||||
/// <summary>"ignore"</summary>
|
||||
Ignore,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines merging tag handling for DAT output
|
||||
/// </summary>
|
||||
public enum MergingFlag
|
||||
{
|
||||
/// <summary>"none"</summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>"split"</summary>
|
||||
Split,
|
||||
|
||||
/// <summary>"merged"</summary>
|
||||
Merged,
|
||||
|
||||
/// <summary>"nonmerged", "unmerged"</summary>
|
||||
NonMerged,
|
||||
|
||||
/// <summary>"fullmerged"</summary>
|
||||
/// <remarks>This is not usually defined for Merging flags</remarks>
|
||||
FullMerged,
|
||||
|
||||
/// <summary>"device", "deviceunmerged", "devicenonmerged"</summary>
|
||||
/// <remarks>This is not usually defined for Merging flags</remarks>
|
||||
DeviceNonMerged,
|
||||
|
||||
/// <summary>"full", "fullunmerged", "fullnonmerged"</summary>
|
||||
/// <remarks>This is not usually defined for Merging flags</remarks>
|
||||
FullNonMerged,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines nodump tag handling for DAT output
|
||||
/// </summary>
|
||||
public enum NodumpFlag
|
||||
{
|
||||
/// <summary>"none"</summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>"obsolete"</summary>
|
||||
Obsolete,
|
||||
|
||||
/// <summary>"required"</summary>
|
||||
Required,
|
||||
|
||||
/// <summary>"ignore"</summary>
|
||||
Ignore,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine which OpenMSX subtype an item is
|
||||
/// </summary>
|
||||
public enum OpenMSXSubType
|
||||
{
|
||||
/// <summary>"rom"</summary>
|
||||
Rom,
|
||||
|
||||
/// <summary>"megarom"</summary>
|
||||
MegaRom,
|
||||
|
||||
/// <summary>"sccpluscart"</summary>
|
||||
SCCPlusCart,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines packing tag handling for DAT output
|
||||
/// </summary>
|
||||
public enum PackingFlag
|
||||
{
|
||||
/// <summary>"none"</summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Force all sets to be in archives, except disk and media
|
||||
/// </summary>
|
||||
/// <remarks>"zip", "yes"</remarks>
|
||||
Zip,
|
||||
|
||||
/// <summary>
|
||||
/// Force all sets to be extracted into subfolders
|
||||
/// </summary>
|
||||
/// <remarks>"unzip", "no"</remarks>
|
||||
Unzip,
|
||||
|
||||
/// <summary>
|
||||
/// Force sets with single items to be extracted to the parent folder
|
||||
/// </summary>
|
||||
/// <remarks>"partial"</remarks>
|
||||
Partial,
|
||||
|
||||
/// <summary>
|
||||
/// Force all sets to be extracted to the parent folder
|
||||
/// </summary>
|
||||
/// <remarks>"flat"</remarks>
|
||||
Flat,
|
||||
|
||||
/// <summary>
|
||||
/// Force all sets to have all archives treated as files
|
||||
/// </summary>
|
||||
/// <remarks>"fileonly"</remarks>
|
||||
FileOnly,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine relation of value to condition
|
||||
/// </summary>
|
||||
public enum Relation
|
||||
{
|
||||
/// <summary>"eq"</summary>
|
||||
Equal,
|
||||
|
||||
/// <summary>"ne"</summary>
|
||||
NotEqual,
|
||||
|
||||
/// <summary>"gt"</summary>
|
||||
GreaterThan,
|
||||
|
||||
/// <summary>"le"</summary>
|
||||
LessThanOrEqual,
|
||||
|
||||
/// <summary>"lt"</summary>
|
||||
LessThan,
|
||||
|
||||
/// <summary>"ge"</summary>
|
||||
GreaterThanOrEqual,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine machine runnable status
|
||||
/// </summary>
|
||||
public enum Runnable
|
||||
{
|
||||
/// <summary>"no"</summary>
|
||||
No,
|
||||
|
||||
/// <summary>"partial"</summary>
|
||||
Partial,
|
||||
|
||||
/// <summary>"yes"</summary>
|
||||
Yes,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine software list status
|
||||
/// </summary>
|
||||
public enum SoftwareListStatus
|
||||
{
|
||||
/// <summary>"none"</summary>
|
||||
None,
|
||||
|
||||
/// <summary>"original"</summary>
|
||||
Original,
|
||||
|
||||
/// <summary>"compatible"</summary>
|
||||
Compatible,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine machine support status
|
||||
/// </summary>
|
||||
public enum Supported
|
||||
{
|
||||
/// <summary>"no", "unsupported"</summary>
|
||||
No,
|
||||
|
||||
/// <summary>"partial"</summary>
|
||||
Partial,
|
||||
|
||||
/// <summary>"yes", "supported"</summary>
|
||||
Yes,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine driver support statuses
|
||||
/// </summary>
|
||||
public enum SupportStatus
|
||||
{
|
||||
/// <summary>"good"</summary>
|
||||
Good,
|
||||
|
||||
/// <summary>"imperfect"</summary>
|
||||
Imperfect,
|
||||
|
||||
/// <summary>"preliminary"</summary>
|
||||
Preliminary,
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using Xunit;
|
||||
|
||||
namespace SabreTools.Metadata.DatFiles.Test
|
||||
{
|
||||
public class ConvertersTests
|
||||
{
|
||||
#region Generators
|
||||
|
||||
[Theory]
|
||||
[InlineData(MergingFlag.None, 12)]
|
||||
[InlineData(NodumpFlag.None, 4)]
|
||||
[InlineData(PackingFlag.None, 8)]
|
||||
public void GenerateToEnumTest<T>(T value, int expected)
|
||||
{
|
||||
var actual = Converters.GenerateToEnum<T>();
|
||||
Assert.Equal(default, value);
|
||||
Assert.Equal(expected, actual.Keys.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SabreTools.Data.Extensions;
|
||||
using SabreTools.Hashing;
|
||||
using SabreTools.Metadata.DatItems;
|
||||
using SabreTools.Metadata.DatItems.Formats;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using SabreTools.Data.Extensions;
|
||||
using SabreTools.Hashing;
|
||||
using SabreTools.Metadata.DatItems;
|
||||
using SabreTools.Metadata.DatItems.Formats;
|
||||
using Xunit;
|
||||
using ItemStatus = SabreTools.Data.Models.Metadata.ItemStatus;
|
||||
|
||||
namespace SabreTools.Metadata.DatFiles.Test
|
||||
{
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
using Xunit;
|
||||
|
||||
namespace SabreTools.Metadata.DatFiles.Test
|
||||
{
|
||||
public class ExtensionsTests
|
||||
{
|
||||
#region String to Enum
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, MergingFlag.None)]
|
||||
[InlineData("none", MergingFlag.None)]
|
||||
[InlineData("split", MergingFlag.Split)]
|
||||
[InlineData("merged", MergingFlag.Merged)]
|
||||
[InlineData("nonmerged", MergingFlag.NonMerged)]
|
||||
[InlineData("unmerged", MergingFlag.NonMerged)]
|
||||
[InlineData("fullmerged", MergingFlag.FullMerged)]
|
||||
[InlineData("device", MergingFlag.DeviceNonMerged)]
|
||||
[InlineData("devicenonmerged", MergingFlag.DeviceNonMerged)]
|
||||
[InlineData("deviceunmerged", MergingFlag.DeviceNonMerged)]
|
||||
[InlineData("full", MergingFlag.FullNonMerged)]
|
||||
[InlineData("fullnonmerged", MergingFlag.FullNonMerged)]
|
||||
[InlineData("fullunmerged", MergingFlag.FullNonMerged)]
|
||||
public void AsMergingFlagTest(string? field, MergingFlag expected)
|
||||
{
|
||||
MergingFlag actual = field.AsMergingFlag();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, NodumpFlag.None)]
|
||||
[InlineData("none", NodumpFlag.None)]
|
||||
[InlineData("obsolete", NodumpFlag.Obsolete)]
|
||||
[InlineData("required", NodumpFlag.Required)]
|
||||
[InlineData("ignore", NodumpFlag.Ignore)]
|
||||
public void AsNodumpFlagTest(string? field, NodumpFlag expected)
|
||||
{
|
||||
NodumpFlag actual = field.AsNodumpFlag();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, PackingFlag.None)]
|
||||
[InlineData("none", PackingFlag.None)]
|
||||
[InlineData("yes", PackingFlag.Zip)]
|
||||
[InlineData("zip", PackingFlag.Zip)]
|
||||
[InlineData("no", PackingFlag.Unzip)]
|
||||
[InlineData("unzip", PackingFlag.Unzip)]
|
||||
[InlineData("partial", PackingFlag.Partial)]
|
||||
[InlineData("flat", PackingFlag.Flat)]
|
||||
[InlineData("fileonly", PackingFlag.FileOnly)]
|
||||
public void AsPackingFlagTest(string? field, PackingFlag expected)
|
||||
{
|
||||
PackingFlag actual = field.AsPackingFlag();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Enum to String
|
||||
|
||||
[Theory]
|
||||
[InlineData(MergingFlag.None, true, "none")]
|
||||
[InlineData(MergingFlag.None, false, "none")]
|
||||
[InlineData(MergingFlag.Split, true, "split")]
|
||||
[InlineData(MergingFlag.Split, false, "split")]
|
||||
[InlineData(MergingFlag.Merged, true, "merged")]
|
||||
[InlineData(MergingFlag.Merged, false, "merged")]
|
||||
[InlineData(MergingFlag.NonMerged, true, "unmerged")]
|
||||
[InlineData(MergingFlag.NonMerged, false, "nonmerged")]
|
||||
[InlineData(MergingFlag.FullMerged, true, "fullmerged")]
|
||||
[InlineData(MergingFlag.FullMerged, false, "fullmerged")]
|
||||
[InlineData(MergingFlag.DeviceNonMerged, true, "deviceunmerged")]
|
||||
[InlineData(MergingFlag.DeviceNonMerged, false, "device")]
|
||||
[InlineData(MergingFlag.FullNonMerged, true, "fullunmerged")]
|
||||
[InlineData(MergingFlag.FullNonMerged, false, "full")]
|
||||
public void FromMergingFlagTest(MergingFlag field, bool useSecond, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue(useSecond);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(NodumpFlag.None, "none")]
|
||||
[InlineData(NodumpFlag.Obsolete, "obsolete")]
|
||||
[InlineData(NodumpFlag.Required, "required")]
|
||||
[InlineData(NodumpFlag.Ignore, "ignore")]
|
||||
public void FromNodumpFlagTest(NodumpFlag field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(PackingFlag.None, true, "none")]
|
||||
[InlineData(PackingFlag.None, false, "none")]
|
||||
[InlineData(PackingFlag.Zip, true, "yes")]
|
||||
[InlineData(PackingFlag.Zip, false, "zip")]
|
||||
[InlineData(PackingFlag.Unzip, true, "no")]
|
||||
[InlineData(PackingFlag.Unzip, false, "unzip")]
|
||||
[InlineData(PackingFlag.Partial, true, "partial")]
|
||||
[InlineData(PackingFlag.Partial, false, "partial")]
|
||||
[InlineData(PackingFlag.Flat, true, "flat")]
|
||||
[InlineData(PackingFlag.Flat, false, "flat")]
|
||||
[InlineData(PackingFlag.FileOnly, true, "fileonly")]
|
||||
[InlineData(PackingFlag.FileOnly, false, "fileonly")]
|
||||
public void FromPackingFlagTest(PackingFlag field, bool useSecond, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue(useSecond);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,10 @@ using System.Threading.Tasks;
|
||||
using SabreTools.Metadata.Filter;
|
||||
using SabreTools.Metadata.DatItems;
|
||||
using SabreTools.Metadata.DatItems.Formats;
|
||||
using SabreTools.Data.Extensions;
|
||||
using MergingFlag = SabreTools.Data.Models.Metadata.MergingFlag;
|
||||
using NodumpFlag = SabreTools.Data.Models.Metadata.NodumpFlag;
|
||||
using PackingFlag = SabreTools.Data.Models.Metadata.PackingFlag;
|
||||
|
||||
#pragma warning disable IDE0056 // Use index operator
|
||||
#pragma warning disable IDE0060 // Remove unused parameter
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SabreTools.Data.Extensions;
|
||||
using SabreTools.Metadata.DatItems;
|
||||
using OpenMSXSubType = SabreTools.Data.Models.Metadata.OpenMSXSubType;
|
||||
|
||||
namespace SabreTools.Metadata.DatFiles
|
||||
{
|
||||
@@ -935,7 +937,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
[Data.Models.Metadata.Video.AspectYKey] = displayItem.ReadLong(Data.Models.Metadata.Video.AspectYKey).ToString(),
|
||||
[Data.Models.Metadata.Video.HeightKey] = displayItem.ReadLong(Data.Models.Metadata.Display.HeightKey).ToString(),
|
||||
[Data.Models.Metadata.Video.RefreshKey] = displayItem.ReadDouble(Data.Models.Metadata.Display.RefreshKey).ToString(),
|
||||
[Data.Models.Metadata.Video.ScreenKey] = displayItem.ReadString(Data.Models.Metadata.Display.DisplayTypeKey).AsDisplayType().AsStringValue(),
|
||||
[Data.Models.Metadata.Video.ScreenKey] = displayItem.ReadString(Data.Models.Metadata.Display.DisplayTypeKey).AsDisplayType()?.AsStringValue(),
|
||||
[Data.Models.Metadata.Video.WidthKey] = displayItem.ReadLong(Data.Models.Metadata.Display.WidthKey).ToString()
|
||||
};
|
||||
|
||||
@@ -1060,8 +1062,6 @@ namespace SabreTools.Metadata.DatFiles
|
||||
EnsureMachineKey<Data.Models.Metadata.Dump?>(machine, Data.Models.Metadata.Machine.DumpKey);
|
||||
AppendToMachineKey(machine, Data.Models.Metadata.Machine.DumpKey, dumpSccPlusCart);
|
||||
break;
|
||||
case OpenMSXSubType.NULL:
|
||||
break;
|
||||
default:
|
||||
// This should never happen
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
using System;
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Data.Extensions;
|
||||
using SabreTools.Metadata.Filter;
|
||||
using MergingFlag = SabreTools.Data.Models.Metadata.MergingFlag;
|
||||
using NodumpFlag = SabreTools.Data.Models.Metadata.NodumpFlag;
|
||||
using PackingFlag = SabreTools.Data.Models.Metadata.PackingFlag;
|
||||
|
||||
namespace SabreTools.Metadata.DatFiles
|
||||
{
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using SabreTools.Data.Extensions;
|
||||
using SabreTools.Hashing;
|
||||
using SabreTools.Metadata.DatItems;
|
||||
using SabreTools.Metadata.DatItems.Formats;
|
||||
using ItemStatus = SabreTools.Data.Models.Metadata.ItemStatus;
|
||||
|
||||
namespace SabreTools.Metadata.DatFiles
|
||||
{
|
||||
@@ -406,7 +408,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
/// <param name="disk">Item to add info from</param>
|
||||
private void AddItemStatistics(Disk disk)
|
||||
{
|
||||
ItemStatus status = disk.ReadString(Data.Models.Metadata.Disk.StatusKey).AsItemStatus();
|
||||
ItemStatus? status = disk.ReadString(Data.Models.Metadata.Disk.StatusKey).AsItemStatus();
|
||||
if (status != ItemStatus.Nodump)
|
||||
{
|
||||
AddHashCount(HashType.MD5, string.IsNullOrEmpty(disk.ReadString(Data.Models.Metadata.Disk.MD5Key)) ? 0 : 1);
|
||||
@@ -425,7 +427,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
/// <param name="disk">Item to add info from</param>
|
||||
private void AddItemStatistics(Data.Models.Metadata.Disk disk)
|
||||
{
|
||||
ItemStatus status = disk.ReadString(Data.Models.Metadata.Disk.StatusKey).AsItemStatus();
|
||||
ItemStatus? status = disk.ReadString(Data.Models.Metadata.Disk.StatusKey).AsItemStatus();
|
||||
if (status != ItemStatus.Nodump)
|
||||
{
|
||||
AddHashCount(HashType.MD5, string.IsNullOrEmpty(disk.ReadString(Data.Models.Metadata.Disk.MD5Key)) ? 0 : 1);
|
||||
@@ -481,7 +483,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
/// <param name="rom">Item to add info from</param>
|
||||
private void AddItemStatistics(Rom rom)
|
||||
{
|
||||
ItemStatus status = rom.ReadString(Data.Models.Metadata.Rom.StatusKey).AsItemStatus();
|
||||
ItemStatus? status = rom.ReadString(Data.Models.Metadata.Rom.StatusKey).AsItemStatus();
|
||||
if (status != ItemStatus.Nodump)
|
||||
{
|
||||
TotalSize += rom.ReadLong(Data.Models.Metadata.Rom.SizeKey) ?? 0;
|
||||
@@ -512,7 +514,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
/// <param name="rom">Item to add info from</param>
|
||||
private void AddItemStatistics(Data.Models.Metadata.Rom rom)
|
||||
{
|
||||
ItemStatus status = rom.ReadString(Data.Models.Metadata.Rom.StatusKey).AsItemStatus();
|
||||
ItemStatus? status = rom.ReadString(Data.Models.Metadata.Rom.StatusKey).AsItemStatus();
|
||||
if (status != ItemStatus.Nodump)
|
||||
{
|
||||
TotalSize += rom.ReadLong(Data.Models.Metadata.Rom.SizeKey) ?? 0;
|
||||
@@ -597,7 +599,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
/// <param name="disk">Item to remove info for</param>
|
||||
private void RemoveItemStatistics(Disk disk)
|
||||
{
|
||||
ItemStatus status = disk.ReadString(Data.Models.Metadata.Disk.StatusKey).AsItemStatus();
|
||||
ItemStatus? status = disk.ReadString(Data.Models.Metadata.Disk.StatusKey).AsItemStatus();
|
||||
if (status != ItemStatus.Nodump)
|
||||
{
|
||||
RemoveHashCount(HashType.MD5, string.IsNullOrEmpty(disk.ReadString(Data.Models.Metadata.Disk.MD5Key)) ? 0 : 1);
|
||||
@@ -616,7 +618,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
/// <param name="disk">Item to remove info for</param>
|
||||
private void RemoveItemStatistics(Data.Models.Metadata.Disk disk)
|
||||
{
|
||||
ItemStatus status = disk.ReadString(Data.Models.Metadata.Disk.StatusKey).AsItemStatus();
|
||||
ItemStatus? status = disk.ReadString(Data.Models.Metadata.Disk.StatusKey).AsItemStatus();
|
||||
if (status != ItemStatus.Nodump)
|
||||
{
|
||||
RemoveHashCount(HashType.MD5, string.IsNullOrEmpty(disk.ReadString(Data.Models.Metadata.Disk.MD5Key)) ? 0 : 1);
|
||||
@@ -672,7 +674,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
/// <param name="rom">Item to remove info for</param>
|
||||
private void RemoveItemStatistics(Rom rom)
|
||||
{
|
||||
ItemStatus status = rom.ReadString(Data.Models.Metadata.Rom.StatusKey).AsItemStatus();
|
||||
ItemStatus? status = rom.ReadString(Data.Models.Metadata.Rom.StatusKey).AsItemStatus();
|
||||
if (status != ItemStatus.Nodump)
|
||||
{
|
||||
TotalSize -= rom.ReadLong(Data.Models.Metadata.Rom.SizeKey) ?? 0;
|
||||
@@ -703,7 +705,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
/// <param name="rom">Item to remove info for</param>
|
||||
private void RemoveItemStatistics(Data.Models.Metadata.Rom rom)
|
||||
{
|
||||
ItemStatus status = rom.ReadString(Data.Models.Metadata.Rom.StatusKey).AsItemStatus();
|
||||
ItemStatus? status = rom.ReadString(Data.Models.Metadata.Rom.StatusKey).AsItemStatus();
|
||||
if (status != ItemStatus.Nodump)
|
||||
{
|
||||
TotalSize -= rom.ReadLong(Data.Models.Metadata.Rom.SizeKey) ?? 0;
|
||||
|
||||
@@ -177,91 +177,4 @@ namespace SabreTools.Metadata.DatFiles
|
||||
// Specialty combinations
|
||||
ALL = ulong.MaxValue,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines merging tag handling for DAT output
|
||||
/// </summary>
|
||||
public enum MergingFlag
|
||||
{
|
||||
[Mapping("none")]
|
||||
None = 0,
|
||||
|
||||
[Mapping("split")]
|
||||
Split,
|
||||
|
||||
[Mapping("merged")]
|
||||
Merged,
|
||||
|
||||
[Mapping("nonmerged", "unmerged")]
|
||||
NonMerged,
|
||||
|
||||
/// <remarks>This is not usually defined for Merging flags</remarks>
|
||||
[Mapping("fullmerged")]
|
||||
FullMerged,
|
||||
|
||||
/// <remarks>This is not usually defined for Merging flags</remarks>
|
||||
[Mapping("device", "deviceunmerged", "devicenonmerged")]
|
||||
DeviceNonMerged,
|
||||
|
||||
/// <remarks>This is not usually defined for Merging flags</remarks>
|
||||
[Mapping("full", "fullunmerged", "fullnonmerged")]
|
||||
FullNonMerged,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines nodump tag handling for DAT output
|
||||
/// </summary>
|
||||
public enum NodumpFlag
|
||||
{
|
||||
[Mapping("none")]
|
||||
None = 0,
|
||||
|
||||
[Mapping("obsolete")]
|
||||
Obsolete,
|
||||
|
||||
[Mapping("required")]
|
||||
Required,
|
||||
|
||||
[Mapping("ignore")]
|
||||
Ignore,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines packing tag handling for DAT output
|
||||
/// </summary>
|
||||
public enum PackingFlag
|
||||
{
|
||||
[Mapping("none")]
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Force all sets to be in archives, except disk and media
|
||||
/// </summary>
|
||||
[Mapping("zip", "yes")]
|
||||
Zip,
|
||||
|
||||
/// <summary>
|
||||
/// Force all sets to be extracted into subfolders
|
||||
/// </summary>
|
||||
[Mapping("unzip", "no")]
|
||||
Unzip,
|
||||
|
||||
/// <summary>
|
||||
/// Force sets with single items to be extracted to the parent folder
|
||||
/// </summary>
|
||||
[Mapping("partial")]
|
||||
Partial,
|
||||
|
||||
/// <summary>
|
||||
/// Force all sets to be extracted to the parent folder
|
||||
/// </summary>
|
||||
[Mapping("flat")]
|
||||
Flat,
|
||||
|
||||
/// <summary>
|
||||
/// Force all sets to have all archives treated as files
|
||||
/// </summary>
|
||||
[Mapping("fileonly")]
|
||||
FileOnly,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SabreTools.Metadata.DatFiles
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
#region Private Maps
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for MergingFlag
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, MergingFlag> _toMergingFlagMap = Converters.GenerateToEnum<MergingFlag>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for MergingFlag
|
||||
/// </summary>
|
||||
private static readonly Dictionary<MergingFlag, string> _fromMergingFlagMap = Converters.GenerateToString<MergingFlag>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for MergingFlag (secondary)
|
||||
/// </summary>
|
||||
private static readonly Dictionary<MergingFlag, string> _fromMergingFlagSecondaryMap = Converters.GenerateToString<MergingFlag>(useSecond: true);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for NodumpFlag
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, NodumpFlag> _toNodumpFlagMap = Converters.GenerateToEnum<NodumpFlag>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for NodumpFlag
|
||||
/// </summary>
|
||||
private static readonly Dictionary<NodumpFlag, string> _fromNodumpFlagMap = Converters.GenerateToString<NodumpFlag>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for PackingFlag
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, PackingFlag> _toPackingFlagMap = Converters.GenerateToEnum<PackingFlag>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for PackingFlag
|
||||
/// </summary>
|
||||
private static readonly Dictionary<PackingFlag, string> _fromPackingFlagMap = Converters.GenerateToString<PackingFlag>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for PackingFlag (secondary)
|
||||
/// </summary>
|
||||
private static readonly Dictionary<PackingFlag, string> _fromPackingFlagSecondaryMap = Converters.GenerateToString<PackingFlag>(useSecond: true);
|
||||
|
||||
#endregion
|
||||
|
||||
#region String to Enum
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static MergingFlag AsMergingFlag(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toMergingFlagMap.TryGetValue(value, out MergingFlag mergingFlag))
|
||||
return mergingFlag;
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static NodumpFlag AsNodumpFlag(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toNodumpFlagMap.TryGetValue(value, out NodumpFlag nodumpFlag))
|
||||
return nodumpFlag;
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static PackingFlag AsPackingFlag(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toPackingFlagMap.TryGetValue(value, out PackingFlag packingFlag))
|
||||
return packingFlag;
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Enum to String
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this MergingFlag value, bool useSecond = false)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (!useSecond && _fromMergingFlagMap.TryGetValue(value, out string? mergingFlag))
|
||||
return mergingFlag;
|
||||
else if (useSecond && _fromMergingFlagSecondaryMap.TryGetValue(value, out string? mergingFlagSecondary))
|
||||
return mergingFlagSecondary;
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this NodumpFlag value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromNodumpFlagMap.TryGetValue(value, out string? nodumpFlag))
|
||||
return nodumpFlag;
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this PackingFlag value, bool useSecond = false)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (!useSecond && _fromPackingFlagMap.TryGetValue(value, out string? packingFlag))
|
||||
return packingFlag;
|
||||
else if (useSecond && _fromPackingFlagSecondaryMap.TryGetValue(value, out string? packingFlagSecondary))
|
||||
return packingFlagSecondary;
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SabreTools.Data.Extensions;
|
||||
using SabreTools.Metadata.DatItems;
|
||||
using SabreTools.Metadata.DatItems.Formats;
|
||||
using SabreTools.Metadata.Filter;
|
||||
@@ -133,14 +134,14 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
break;
|
||||
|
||||
case Chip chip:
|
||||
if (chip.ReadString(Data.Models.Metadata.Chip.ChipTypeKey).AsChipType() == ChipType.NULL)
|
||||
if (chip.ReadString(Data.Models.Metadata.Chip.ChipTypeKey).AsChipType() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Chip.ChipTypeKey);
|
||||
if (string.IsNullOrEmpty(chip.GetName()))
|
||||
missingFields.Add(Data.Models.Metadata.Chip.NameKey);
|
||||
break;
|
||||
|
||||
case Display display:
|
||||
if (display.ReadString(Data.Models.Metadata.Display.DisplayTypeKey).AsDisplayType() == DisplayType.NULL)
|
||||
if (display.ReadString(Data.Models.Metadata.Display.DisplayTypeKey).AsDisplayType() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Display.DisplayTypeKey);
|
||||
if (display.ReadLong(Data.Models.Metadata.Display.RotateKey) is null)
|
||||
missingFields.Add(Data.Models.Metadata.Display.RotateKey);
|
||||
@@ -164,9 +165,9 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
break;
|
||||
|
||||
case Driver driver:
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.StatusKey).AsSupportStatus() == SupportStatus.NULL)
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.StatusKey).AsSupportStatus() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Driver.StatusKey);
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.EmulationKey).AsSupportStatus() == SupportStatus.NULL)
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.EmulationKey).AsSupportStatus() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Driver.EmulationKey);
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SabreTools.Data.Extensions;
|
||||
using SabreTools.Metadata.DatItems;
|
||||
using SabreTools.Metadata.DatItems.Formats;
|
||||
using SabreTools.Metadata.Filter;
|
||||
@@ -303,12 +304,12 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
case Chip chip:
|
||||
if (string.IsNullOrEmpty(chip.GetName()))
|
||||
missingFields.Add(Data.Models.Metadata.Chip.NameKey);
|
||||
if (chip.ReadString(Data.Models.Metadata.Chip.ChipTypeKey).AsChipType() == ChipType.NULL)
|
||||
if (chip.ReadString(Data.Models.Metadata.Chip.ChipTypeKey).AsChipType() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Chip.ChipTypeKey);
|
||||
break;
|
||||
|
||||
case Display display:
|
||||
if (display.ReadString(Data.Models.Metadata.Display.DisplayTypeKey).AsDisplayType() == DisplayType.NULL)
|
||||
if (display.ReadString(Data.Models.Metadata.Display.DisplayTypeKey).AsDisplayType() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Display.DisplayTypeKey);
|
||||
if (display.ReadDouble(Data.Models.Metadata.Display.RefreshKey) is null)
|
||||
missingFields.Add(Data.Models.Metadata.Display.RefreshKey);
|
||||
@@ -349,23 +350,23 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
break;
|
||||
|
||||
case Driver driver:
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.StatusKey).AsSupportStatus() == SupportStatus.NULL)
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.StatusKey).AsSupportStatus() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Driver.StatusKey);
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.EmulationKey).AsSupportStatus() == SupportStatus.NULL)
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.EmulationKey).AsSupportStatus() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Driver.EmulationKey);
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.CocktailKey).AsSupportStatus() == SupportStatus.NULL)
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.CocktailKey).AsSupportStatus() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Driver.CocktailKey);
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.SaveStateKey).AsSupportStatus() == SupportStatus.NULL)
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.SaveStateKey).AsSupportStatus() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Driver.SaveStateKey);
|
||||
break;
|
||||
|
||||
case Feature feature:
|
||||
if (feature.ReadString(Data.Models.Metadata.Feature.FeatureTypeKey).AsFeatureType() == FeatureType.NULL)
|
||||
if (feature.ReadString(Data.Models.Metadata.Feature.FeatureTypeKey).AsFeatureType() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Feature.FeatureTypeKey);
|
||||
break;
|
||||
|
||||
case Device device:
|
||||
if (device.ReadString(Data.Models.Metadata.Device.DeviceTypeKey).AsDeviceType() == DeviceType.NULL)
|
||||
if (device.ReadString(Data.Models.Metadata.Device.DeviceTypeKey).AsDeviceType() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Device.DeviceTypeKey);
|
||||
break;
|
||||
|
||||
@@ -379,7 +380,7 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
missingFields.Add(Data.Models.Metadata.SoftwareList.TagKey);
|
||||
if (string.IsNullOrEmpty(softwarelist.GetName()))
|
||||
missingFields.Add(Data.Models.Metadata.SoftwareList.NameKey);
|
||||
if (softwarelist.ReadString(Data.Models.Metadata.SoftwareList.StatusKey).AsSoftwareListStatus() == SoftwareListStatus.None)
|
||||
if (softwarelist.ReadString(Data.Models.Metadata.SoftwareList.StatusKey).AsSoftwareListStatus() == null)
|
||||
missingFields.Add(Data.Models.Metadata.SoftwareList.StatusKey);
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SabreTools.Data.Extensions;
|
||||
using SabreTools.Metadata.DatItems;
|
||||
using SabreTools.Metadata.DatItems.Formats;
|
||||
|
||||
@@ -343,13 +344,13 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
break;
|
||||
|
||||
case Driver driver:
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.StatusKey).AsSupportStatus() == SupportStatus.NULL)
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.StatusKey).AsSupportStatus() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Driver.StatusKey);
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.EmulationKey).AsSupportStatus() == SupportStatus.NULL)
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.EmulationKey).AsSupportStatus() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Driver.EmulationKey);
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.CocktailKey).AsSupportStatus() == SupportStatus.NULL)
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.CocktailKey).AsSupportStatus() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Driver.CocktailKey);
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.SaveStateKey).AsSupportStatus() == SupportStatus.NULL)
|
||||
if (driver.ReadString(Data.Models.Metadata.Driver.SaveStateKey).AsSupportStatus() is null)
|
||||
missingFields.Add(Data.Models.Metadata.Driver.SaveStateKey);
|
||||
break;
|
||||
|
||||
@@ -358,7 +359,7 @@ namespace SabreTools.Metadata.DatFiles.Formats
|
||||
missingFields.Add(Data.Models.Metadata.SoftwareList.TagKey);
|
||||
if (string.IsNullOrEmpty(softwarelist.GetName()))
|
||||
missingFields.Add(Data.Models.Metadata.SoftwareList.NameKey);
|
||||
if (softwarelist.ReadString(Data.Models.Metadata.SoftwareList.StatusKey).AsSoftwareListStatus() == SoftwareListStatus.None)
|
||||
if (softwarelist.ReadString(Data.Models.Metadata.SoftwareList.StatusKey).AsSoftwareListStatus() == null)
|
||||
missingFields.Add(Data.Models.Metadata.SoftwareList.StatusKey);
|
||||
break;
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ using SabreTools.Hashing;
|
||||
using SabreTools.Logging;
|
||||
using SabreTools.Text.Compare;
|
||||
using SabreTools.Text.Extensions;
|
||||
using SabreTools.Data.Extensions;
|
||||
using ItemStatus = SabreTools.Data.Models.Metadata.ItemStatus;
|
||||
|
||||
namespace SabreTools.Metadata.DatFiles
|
||||
{
|
||||
|
||||
@@ -16,6 +16,8 @@ using SabreTools.Hashing;
|
||||
using SabreTools.Logging;
|
||||
using SabreTools.Text.Compare;
|
||||
using SabreTools.Text.Extensions;
|
||||
using SabreTools.Data.Extensions;
|
||||
using ItemStatus = SabreTools.Data.Models.Metadata.ItemStatus;
|
||||
|
||||
/*
|
||||
* Planning Notes:
|
||||
@@ -451,7 +453,7 @@ namespace SabreTools.Metadata.DatFiles
|
||||
/// </summary>
|
||||
public Source? GetSource(long index)
|
||||
{
|
||||
if (!_sources.TryGetValue(index, out var source))
|
||||
if (_sources.TryGetValue(index, out var source))
|
||||
return source;
|
||||
|
||||
return null;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
using Xunit;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Test
|
||||
{
|
||||
public class ConvertersTests
|
||||
{
|
||||
#region Generators
|
||||
|
||||
[Theory]
|
||||
[InlineData(ChipType.NULL, 2)]
|
||||
[InlineData(ControlType.NULL, 15)]
|
||||
[InlineData(DeviceType.NULL, 21)]
|
||||
[InlineData(DisplayType.NULL, 5)]
|
||||
[InlineData(Endianness.NULL, 2)]
|
||||
[InlineData(FeatureStatus.NULL, 2)]
|
||||
[InlineData(FeatureType.NULL, 14)]
|
||||
[InlineData(ItemStatus.NULL, 7)]
|
||||
[InlineData(ItemType.NULL, 54)]
|
||||
[InlineData(LoadFlag.NULL, 14)]
|
||||
[InlineData(MachineType.None, 6)]
|
||||
[InlineData(OpenMSXSubType.NULL, 3)]
|
||||
[InlineData(Relation.NULL, 6)]
|
||||
[InlineData(Runnable.NULL, 3)]
|
||||
[InlineData(SoftwareListStatus.None, 3)]
|
||||
[InlineData(Supported.NULL, 5)]
|
||||
[InlineData(SupportStatus.NULL, 3)]
|
||||
public void GenerateToEnumTest<T>(T value, int expected)
|
||||
{
|
||||
var actual = Converters.GenerateToEnum<T>();
|
||||
Assert.Equal(default, value);
|
||||
Assert.Equal(expected, actual.Keys.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,138 +6,6 @@ namespace SabreTools.Metadata.DatItems.Test
|
||||
{
|
||||
#region String to Enum
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, ChipType.NULL)]
|
||||
[InlineData("cpu", ChipType.CPU)]
|
||||
[InlineData("audio", ChipType.Audio)]
|
||||
public void AsChipTypeTest(string? field, ChipType expected)
|
||||
{
|
||||
ChipType actual = field.AsChipType();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, ControlType.NULL)]
|
||||
[InlineData("joy", ControlType.Joy)]
|
||||
[InlineData("stick", ControlType.Stick)]
|
||||
[InlineData("paddle", ControlType.Paddle)]
|
||||
[InlineData("pedal", ControlType.Pedal)]
|
||||
[InlineData("lightgun", ControlType.Lightgun)]
|
||||
[InlineData("positional", ControlType.Positional)]
|
||||
[InlineData("dial", ControlType.Dial)]
|
||||
[InlineData("trackball", ControlType.Trackball)]
|
||||
[InlineData("mouse", ControlType.Mouse)]
|
||||
[InlineData("only_buttons", ControlType.OnlyButtons)]
|
||||
[InlineData("keypad", ControlType.Keypad)]
|
||||
[InlineData("keyboard", ControlType.Keyboard)]
|
||||
[InlineData("mahjong", ControlType.Mahjong)]
|
||||
[InlineData("hanafuda", ControlType.Hanafuda)]
|
||||
[InlineData("gambling", ControlType.Gambling)]
|
||||
public void AsControlTypeTest(string? field, ControlType expected)
|
||||
{
|
||||
ControlType actual = field.AsControlType();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, DeviceType.NULL)]
|
||||
[InlineData("unknown", DeviceType.Unknown)]
|
||||
[InlineData("cartridge", DeviceType.Cartridge)]
|
||||
[InlineData("floppydisk", DeviceType.FloppyDisk)]
|
||||
[InlineData("harddisk", DeviceType.HardDisk)]
|
||||
[InlineData("cylinder", DeviceType.Cylinder)]
|
||||
[InlineData("cassette", DeviceType.Cassette)]
|
||||
[InlineData("punchcard", DeviceType.PunchCard)]
|
||||
[InlineData("punchtape", DeviceType.PunchTape)]
|
||||
[InlineData("printout", DeviceType.Printout)]
|
||||
[InlineData("serial", DeviceType.Serial)]
|
||||
[InlineData("parallel", DeviceType.Parallel)]
|
||||
[InlineData("snapshot", DeviceType.Snapshot)]
|
||||
[InlineData("quickload", DeviceType.QuickLoad)]
|
||||
[InlineData("memcard", DeviceType.MemCard)]
|
||||
[InlineData("cdrom", DeviceType.CDROM)]
|
||||
[InlineData("magtape", DeviceType.MagTape)]
|
||||
[InlineData("romimage", DeviceType.ROMImage)]
|
||||
[InlineData("midiin", DeviceType.MIDIIn)]
|
||||
[InlineData("midiout", DeviceType.MIDIOut)]
|
||||
[InlineData("picture", DeviceType.Picture)]
|
||||
[InlineData("vidfile", DeviceType.VidFile)]
|
||||
public void AsDeviceTypeTest(string? field, DeviceType expected)
|
||||
{
|
||||
DeviceType actual = field.AsDeviceType();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, DisplayType.NULL)]
|
||||
[InlineData("raster", DisplayType.Raster)]
|
||||
[InlineData("vector", DisplayType.Vector)]
|
||||
[InlineData("lcd", DisplayType.LCD)]
|
||||
[InlineData("svg", DisplayType.SVG)]
|
||||
[InlineData("unknown", DisplayType.Unknown)]
|
||||
public void AsDisplayTypeTest(string? field, DisplayType expected)
|
||||
{
|
||||
DisplayType actual = field.AsDisplayType();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, Endianness.NULL)]
|
||||
[InlineData("big", Endianness.Big)]
|
||||
[InlineData("little", Endianness.Little)]
|
||||
public void AsEndiannessTest(string? field, Endianness expected)
|
||||
{
|
||||
Endianness actual = field.AsEndianness();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, FeatureStatus.NULL)]
|
||||
[InlineData("unemulated", FeatureStatus.Unemulated)]
|
||||
[InlineData("imperfect", FeatureStatus.Imperfect)]
|
||||
public void AsFeatureStatusTest(string? field, FeatureStatus expected)
|
||||
{
|
||||
FeatureStatus actual = field.AsFeatureStatus();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, FeatureType.NULL)]
|
||||
[InlineData("protection", FeatureType.Protection)]
|
||||
[InlineData("palette", FeatureType.Palette)]
|
||||
[InlineData("graphics", FeatureType.Graphics)]
|
||||
[InlineData("sound", FeatureType.Sound)]
|
||||
[InlineData("controls", FeatureType.Controls)]
|
||||
[InlineData("keyboard", FeatureType.Keyboard)]
|
||||
[InlineData("mouse", FeatureType.Mouse)]
|
||||
[InlineData("microphone", FeatureType.Microphone)]
|
||||
[InlineData("camera", FeatureType.Camera)]
|
||||
[InlineData("disk", FeatureType.Disk)]
|
||||
[InlineData("printer", FeatureType.Printer)]
|
||||
[InlineData("lan", FeatureType.Lan)]
|
||||
[InlineData("wan", FeatureType.Wan)]
|
||||
[InlineData("timing", FeatureType.Timing)]
|
||||
public void AsFeatureTypeTest(string? field, FeatureType expected)
|
||||
{
|
||||
FeatureType actual = field.AsFeatureType();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, ItemStatus.NULL)]
|
||||
[InlineData("none", ItemStatus.None)]
|
||||
[InlineData("no", ItemStatus.None)]
|
||||
[InlineData("good", ItemStatus.Good)]
|
||||
[InlineData("baddump", ItemStatus.BadDump)]
|
||||
[InlineData("nodump", ItemStatus.Nodump)]
|
||||
[InlineData("yes", ItemStatus.Nodump)]
|
||||
[InlineData("verified", ItemStatus.Verified)]
|
||||
public void AsItemStatusTest(string? field, ItemStatus expected)
|
||||
{
|
||||
ItemStatus actual = field.AsItemStatus();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, ItemType.NULL)]
|
||||
[InlineData("adjuster", ItemType.Adjuster)]
|
||||
@@ -199,28 +67,6 @@ namespace SabreTools.Metadata.DatItems.Test
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, LoadFlag.NULL)]
|
||||
[InlineData("load16_byte", LoadFlag.Load16Byte)]
|
||||
[InlineData("load16_word", LoadFlag.Load16Word)]
|
||||
[InlineData("load16_word_swap", LoadFlag.Load16WordSwap)]
|
||||
[InlineData("load32_byte", LoadFlag.Load32Byte)]
|
||||
[InlineData("load32_word", LoadFlag.Load32Word)]
|
||||
[InlineData("load32_word_swap", LoadFlag.Load32WordSwap)]
|
||||
[InlineData("load32_dword", LoadFlag.Load32DWord)]
|
||||
[InlineData("load64_word", LoadFlag.Load64Word)]
|
||||
[InlineData("load64_word_swap", LoadFlag.Load64WordSwap)]
|
||||
[InlineData("reload", LoadFlag.Reload)]
|
||||
[InlineData("fill", LoadFlag.Fill)]
|
||||
[InlineData("continue", LoadFlag.Continue)]
|
||||
[InlineData("reload_plain", LoadFlag.ReloadPlain)]
|
||||
[InlineData("ignore", LoadFlag.Ignore)]
|
||||
public void AsLoadFlagTest(string? field, LoadFlag expected)
|
||||
{
|
||||
LoadFlag actual = field.AsLoadFlag();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, MachineType.None)]
|
||||
[InlineData("none", MachineType.None)]
|
||||
@@ -235,211 +81,10 @@ namespace SabreTools.Metadata.DatItems.Test
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, OpenMSXSubType.NULL)]
|
||||
[InlineData("rom", OpenMSXSubType.Rom)]
|
||||
[InlineData("megarom", OpenMSXSubType.MegaRom)]
|
||||
[InlineData("sccpluscart", OpenMSXSubType.SCCPlusCart)]
|
||||
public void AsOpenMSXSubTypeTest(string? field, OpenMSXSubType expected)
|
||||
{
|
||||
OpenMSXSubType actual = field.AsOpenMSXSubType();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, Relation.NULL)]
|
||||
[InlineData("eq", Relation.Equal)]
|
||||
[InlineData("ne", Relation.NotEqual)]
|
||||
[InlineData("gt", Relation.GreaterThan)]
|
||||
[InlineData("le", Relation.LessThanOrEqual)]
|
||||
[InlineData("lt", Relation.LessThan)]
|
||||
[InlineData("ge", Relation.GreaterThanOrEqual)]
|
||||
public void AsRelationTest(string? field, Relation expected)
|
||||
{
|
||||
Relation actual = field.AsRelation();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, Runnable.NULL)]
|
||||
[InlineData("no", Runnable.No)]
|
||||
[InlineData("partial", Runnable.Partial)]
|
||||
[InlineData("yes", Runnable.Yes)]
|
||||
public void AsRunnableTest(string? field, Runnable expected)
|
||||
{
|
||||
Runnable actual = field.AsRunnable();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, SoftwareListStatus.None)]
|
||||
[InlineData("none", SoftwareListStatus.None)]
|
||||
[InlineData("original", SoftwareListStatus.Original)]
|
||||
[InlineData("compatible", SoftwareListStatus.Compatible)]
|
||||
public void AsSoftwareListStatusTest(string? field, SoftwareListStatus expected)
|
||||
{
|
||||
SoftwareListStatus actual = field.AsSoftwareListStatus();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, Supported.NULL)]
|
||||
[InlineData("no", Supported.No)]
|
||||
[InlineData("unsupported", Supported.No)]
|
||||
[InlineData("partial", Supported.Partial)]
|
||||
[InlineData("yes", Supported.Yes)]
|
||||
[InlineData("supported", Supported.Yes)]
|
||||
public void AsSupportedTest(string? field, Supported expected)
|
||||
{
|
||||
Supported actual = field.AsSupported();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, SupportStatus.NULL)]
|
||||
[InlineData("good", SupportStatus.Good)]
|
||||
[InlineData("imperfect", SupportStatus.Imperfect)]
|
||||
[InlineData("preliminary", SupportStatus.Preliminary)]
|
||||
public void AsSupportStatusTest(string? field, SupportStatus expected)
|
||||
{
|
||||
SupportStatus actual = field.AsSupportStatus();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Enum to String
|
||||
|
||||
[Theory]
|
||||
[InlineData(ChipType.NULL, null)]
|
||||
[InlineData(ChipType.CPU, "cpu")]
|
||||
[InlineData(ChipType.Audio, "audio")]
|
||||
public void FromChipTypeTest(ChipType field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(ControlType.NULL, null)]
|
||||
[InlineData(ControlType.Joy, "joy")]
|
||||
[InlineData(ControlType.Stick, "stick")]
|
||||
[InlineData(ControlType.Paddle, "paddle")]
|
||||
[InlineData(ControlType.Pedal, "pedal")]
|
||||
[InlineData(ControlType.Lightgun, "lightgun")]
|
||||
[InlineData(ControlType.Positional, "positional")]
|
||||
[InlineData(ControlType.Dial, "dial")]
|
||||
[InlineData(ControlType.Trackball, "trackball")]
|
||||
[InlineData(ControlType.Mouse, "mouse")]
|
||||
[InlineData(ControlType.OnlyButtons, "only_buttons")]
|
||||
[InlineData(ControlType.Keypad, "keypad")]
|
||||
[InlineData(ControlType.Keyboard, "keyboard")]
|
||||
[InlineData(ControlType.Mahjong, "mahjong")]
|
||||
[InlineData(ControlType.Hanafuda, "hanafuda")]
|
||||
[InlineData(ControlType.Gambling, "gambling")]
|
||||
public void FromControlTypeTest(ControlType field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(DeviceType.NULL, null)]
|
||||
[InlineData(DeviceType.Unknown, "unknown")]
|
||||
[InlineData(DeviceType.Cartridge, "cartridge")]
|
||||
[InlineData(DeviceType.FloppyDisk, "floppydisk")]
|
||||
[InlineData(DeviceType.HardDisk, "harddisk")]
|
||||
[InlineData(DeviceType.Cylinder, "cylinder")]
|
||||
[InlineData(DeviceType.Cassette, "cassette")]
|
||||
[InlineData(DeviceType.PunchCard, "punchcard")]
|
||||
[InlineData(DeviceType.PunchTape, "punchtape")]
|
||||
[InlineData(DeviceType.Printout, "printout")]
|
||||
[InlineData(DeviceType.Serial, "serial")]
|
||||
[InlineData(DeviceType.Parallel, "parallel")]
|
||||
[InlineData(DeviceType.Snapshot, "snapshot")]
|
||||
[InlineData(DeviceType.QuickLoad, "quickload")]
|
||||
[InlineData(DeviceType.MemCard, "memcard")]
|
||||
[InlineData(DeviceType.CDROM, "cdrom")]
|
||||
[InlineData(DeviceType.MagTape, "magtape")]
|
||||
[InlineData(DeviceType.ROMImage, "romimage")]
|
||||
[InlineData(DeviceType.MIDIIn, "midiin")]
|
||||
[InlineData(DeviceType.MIDIOut, "midiout")]
|
||||
[InlineData(DeviceType.Picture, "picture")]
|
||||
[InlineData(DeviceType.VidFile, "vidfile")]
|
||||
public void FromDeviceTypeTest(DeviceType field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(DisplayType.NULL, null)]
|
||||
[InlineData(DisplayType.Raster, "raster")]
|
||||
[InlineData(DisplayType.Vector, "vector")]
|
||||
[InlineData(DisplayType.LCD, "lcd")]
|
||||
[InlineData(DisplayType.SVG, "svg")]
|
||||
[InlineData(DisplayType.Unknown, "unknown")]
|
||||
public void FromDisplayTypeTest(DisplayType field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(Endianness.NULL, null)]
|
||||
[InlineData(Endianness.Big, "big")]
|
||||
[InlineData(Endianness.Little, "little")]
|
||||
public void FromEndiannessTest(Endianness field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(FeatureStatus.NULL, null)]
|
||||
[InlineData(FeatureStatus.Unemulated, "unemulated")]
|
||||
[InlineData(FeatureStatus.Imperfect, "imperfect")]
|
||||
public void FromFeatureStatusTest(FeatureStatus field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(FeatureType.NULL, null)]
|
||||
[InlineData(FeatureType.Protection, "protection")]
|
||||
[InlineData(FeatureType.Palette, "palette")]
|
||||
[InlineData(FeatureType.Graphics, "graphics")]
|
||||
[InlineData(FeatureType.Sound, "sound")]
|
||||
[InlineData(FeatureType.Controls, "controls")]
|
||||
[InlineData(FeatureType.Keyboard, "keyboard")]
|
||||
[InlineData(FeatureType.Mouse, "mouse")]
|
||||
[InlineData(FeatureType.Microphone, "microphone")]
|
||||
[InlineData(FeatureType.Camera, "camera")]
|
||||
[InlineData(FeatureType.Disk, "disk")]
|
||||
[InlineData(FeatureType.Printer, "printer")]
|
||||
[InlineData(FeatureType.Lan, "lan")]
|
||||
[InlineData(FeatureType.Wan, "wan")]
|
||||
[InlineData(FeatureType.Timing, "timing")]
|
||||
public void FromFeatureTypeTest(FeatureType field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(ItemStatus.NULL, null)]
|
||||
[InlineData(ItemStatus.None, "none")]
|
||||
[InlineData(ItemStatus.Good, "good")]
|
||||
[InlineData(ItemStatus.BadDump, "baddump")]
|
||||
[InlineData(ItemStatus.Nodump, "nodump")]
|
||||
[InlineData(ItemStatus.Verified, "verified")]
|
||||
public void FromItemStatusTest(ItemStatus field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(ItemType.NULL, null)]
|
||||
[InlineData(ItemType.Adjuster, "adjuster")]
|
||||
@@ -491,100 +136,6 @@ namespace SabreTools.Metadata.DatItems.Test
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(LoadFlag.NULL, null)]
|
||||
[InlineData(LoadFlag.Load16Byte, "load16_byte")]
|
||||
[InlineData(LoadFlag.Load16Word, "load16_word")]
|
||||
[InlineData(LoadFlag.Load16WordSwap, "load16_word_swap")]
|
||||
[InlineData(LoadFlag.Load32Byte, "load32_byte")]
|
||||
[InlineData(LoadFlag.Load32Word, "load32_word")]
|
||||
[InlineData(LoadFlag.Load32WordSwap, "load32_word_swap")]
|
||||
[InlineData(LoadFlag.Load32DWord, "load32_dword")]
|
||||
[InlineData(LoadFlag.Load64Word, "load64_word")]
|
||||
[InlineData(LoadFlag.Load64WordSwap, "load64_word_swap")]
|
||||
[InlineData(LoadFlag.Reload, "reload")]
|
||||
[InlineData(LoadFlag.Fill, "fill")]
|
||||
[InlineData(LoadFlag.Continue, "continue")]
|
||||
[InlineData(LoadFlag.ReloadPlain, "reload_plain")]
|
||||
[InlineData(LoadFlag.Ignore, "ignore")]
|
||||
public void FromLoadFlagTest(LoadFlag field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(OpenMSXSubType.NULL, null)]
|
||||
[InlineData(OpenMSXSubType.Rom, "rom")]
|
||||
[InlineData(OpenMSXSubType.MegaRom, "megarom")]
|
||||
[InlineData(OpenMSXSubType.SCCPlusCart, "sccpluscart")]
|
||||
public void FromOpenMSXSubTypeTest(OpenMSXSubType field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(Relation.NULL, null)]
|
||||
[InlineData(Relation.Equal, "eq")]
|
||||
[InlineData(Relation.NotEqual, "ne")]
|
||||
[InlineData(Relation.GreaterThan, "gt")]
|
||||
[InlineData(Relation.LessThanOrEqual, "le")]
|
||||
[InlineData(Relation.LessThan, "lt")]
|
||||
[InlineData(Relation.GreaterThanOrEqual, "ge")]
|
||||
public void FromRelationTest(Relation field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(Runnable.NULL, null)]
|
||||
[InlineData(Runnable.No, "no")]
|
||||
[InlineData(Runnable.Partial, "partial")]
|
||||
[InlineData(Runnable.Yes, "yes")]
|
||||
public void FromRunnableTest(Runnable field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(SoftwareListStatus.None, "none")]
|
||||
[InlineData(SoftwareListStatus.Original, "original")]
|
||||
[InlineData(SoftwareListStatus.Compatible, "compatible")]
|
||||
public void FromSoftwareListStatusTest(SoftwareListStatus field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(Supported.NULL, true, null)]
|
||||
[InlineData(Supported.NULL, false, null)]
|
||||
[InlineData(Supported.No, true, "unsupported")]
|
||||
[InlineData(Supported.No, false, "no")]
|
||||
[InlineData(Supported.Partial, true, "partial")]
|
||||
[InlineData(Supported.Partial, false, "partial")]
|
||||
[InlineData(Supported.Yes, true, "supported")]
|
||||
[InlineData(Supported.Yes, false, "yes")]
|
||||
public void FromSupportedTest(Supported field, bool useSecond, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue(useSecond);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(SupportStatus.NULL, null)]
|
||||
[InlineData(SupportStatus.Good, "good")]
|
||||
[InlineData(SupportStatus.Imperfect, "imperfect")]
|
||||
[InlineData(SupportStatus.Preliminary, "preliminary")]
|
||||
public void FromSupportStatusTest(SupportStatus field, string? expected)
|
||||
{
|
||||
string? actual = field.AsStringValue();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,183 +2,6 @@ using System;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Determine the chip type
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ChipType
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
[Mapping("cpu")]
|
||||
CPU = 1 << 0,
|
||||
|
||||
[Mapping("audio")]
|
||||
Audio = 1 << 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the control type
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ControlType
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
[Mapping("joy")]
|
||||
Joy = 1 << 0,
|
||||
|
||||
[Mapping("stick")]
|
||||
Stick = 1 << 1,
|
||||
|
||||
[Mapping("paddle")]
|
||||
Paddle = 1 << 2,
|
||||
|
||||
[Mapping("pedal")]
|
||||
Pedal = 1 << 3,
|
||||
|
||||
[Mapping("lightgun")]
|
||||
Lightgun = 1 << 4,
|
||||
|
||||
[Mapping("positional")]
|
||||
Positional = 1 << 5,
|
||||
|
||||
[Mapping("dial")]
|
||||
Dial = 1 << 6,
|
||||
|
||||
[Mapping("trackball")]
|
||||
Trackball = 1 << 7,
|
||||
|
||||
[Mapping("mouse")]
|
||||
Mouse = 1 << 8,
|
||||
|
||||
[Mapping("only_buttons")]
|
||||
OnlyButtons = 1 << 9,
|
||||
|
||||
[Mapping("keypad")]
|
||||
Keypad = 1 << 10,
|
||||
|
||||
[Mapping("keyboard")]
|
||||
Keyboard = 1 << 11,
|
||||
|
||||
[Mapping("mahjong")]
|
||||
Mahjong = 1 << 12,
|
||||
|
||||
[Mapping("hanafuda")]
|
||||
Hanafuda = 1 << 13,
|
||||
|
||||
[Mapping("gambling")]
|
||||
Gambling = 1 << 14,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the device type
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum DeviceType
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
[Mapping("unknown")]
|
||||
Unknown = 1 << 0,
|
||||
|
||||
[Mapping("cartridge")]
|
||||
Cartridge = 1 << 1,
|
||||
|
||||
[Mapping("floppydisk")]
|
||||
FloppyDisk = 1 << 2,
|
||||
|
||||
[Mapping("harddisk")]
|
||||
HardDisk = 1 << 3,
|
||||
|
||||
[Mapping("cylinder")]
|
||||
Cylinder = 1 << 4,
|
||||
|
||||
[Mapping("cassette")]
|
||||
Cassette = 1 << 5,
|
||||
|
||||
[Mapping("punchcard")]
|
||||
PunchCard = 1 << 6,
|
||||
|
||||
[Mapping("punchtape")]
|
||||
PunchTape = 1 << 7,
|
||||
|
||||
[Mapping("printout")]
|
||||
Printout = 1 << 8,
|
||||
|
||||
[Mapping("serial")]
|
||||
Serial = 1 << 9,
|
||||
|
||||
[Mapping("parallel")]
|
||||
Parallel = 1 << 10,
|
||||
|
||||
[Mapping("snapshot")]
|
||||
Snapshot = 1 << 11,
|
||||
|
||||
[Mapping("quickload")]
|
||||
QuickLoad = 1 << 12,
|
||||
|
||||
[Mapping("memcard")]
|
||||
MemCard = 1 << 13,
|
||||
|
||||
[Mapping("cdrom")]
|
||||
CDROM = 1 << 14,
|
||||
|
||||
[Mapping("magtape")]
|
||||
MagTape = 1 << 15,
|
||||
|
||||
[Mapping("romimage")]
|
||||
ROMImage = 1 << 16,
|
||||
|
||||
[Mapping("midiin")]
|
||||
MIDIIn = 1 << 17,
|
||||
|
||||
[Mapping("midiout")]
|
||||
MIDIOut = 1 << 18,
|
||||
|
||||
[Mapping("picture")]
|
||||
Picture = 1 << 19,
|
||||
|
||||
[Mapping("vidfile")]
|
||||
VidFile = 1 << 20,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the display type
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum DisplayType
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
[Mapping("raster")]
|
||||
Raster = 1 << 0,
|
||||
|
||||
[Mapping("vector")]
|
||||
Vector = 1 << 1,
|
||||
|
||||
[Mapping("lcd")]
|
||||
LCD = 1 << 2,
|
||||
|
||||
[Mapping("svg")]
|
||||
SVG = 1 << 3,
|
||||
|
||||
[Mapping("unknown")]
|
||||
Unknown = 1 << 4,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines which type of duplicate a file is
|
||||
/// </summary>
|
||||
@@ -194,96 +17,6 @@ namespace SabreTools.Metadata.DatItems
|
||||
External = 1 << 3,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the endianness
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum Endianness
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
[Mapping("big")]
|
||||
Big = 1 << 0,
|
||||
|
||||
[Mapping("little")]
|
||||
Little = 1 << 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the emulation status
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum FeatureStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
[Mapping("unemulated")]
|
||||
Unemulated = 1 << 0,
|
||||
|
||||
[Mapping("imperfect")]
|
||||
Imperfect = 1 << 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the feature type
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum FeatureType
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
[Mapping("protection")]
|
||||
Protection = 1 << 0,
|
||||
|
||||
[Mapping("palette")]
|
||||
Palette = 1 << 1,
|
||||
|
||||
[Mapping("graphics")]
|
||||
Graphics = 1 << 2,
|
||||
|
||||
[Mapping("sound")]
|
||||
Sound = 1 << 3,
|
||||
|
||||
[Mapping("controls")]
|
||||
Controls = 1 << 4,
|
||||
|
||||
[Mapping("keyboard")]
|
||||
Keyboard = 1 << 5,
|
||||
|
||||
[Mapping("mouse")]
|
||||
Mouse = 1 << 6,
|
||||
|
||||
[Mapping("microphone")]
|
||||
Microphone = 1 << 7,
|
||||
|
||||
[Mapping("camera")]
|
||||
Camera = 1 << 8,
|
||||
|
||||
[Mapping("disk")]
|
||||
Disk = 1 << 9,
|
||||
|
||||
[Mapping("printer")]
|
||||
Printer = 1 << 10,
|
||||
|
||||
[Mapping("lan")]
|
||||
Lan = 1 << 11,
|
||||
|
||||
[Mapping("wan")]
|
||||
Wan = 1 << 12,
|
||||
|
||||
[Mapping("timing")]
|
||||
Timing = 1 << 13,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A subset of fields that can be used as keys
|
||||
/// </summary>
|
||||
@@ -308,33 +41,6 @@ namespace SabreTools.Metadata.DatItems
|
||||
SpamSum,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the status of the item
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ItemStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
[Mapping("none", "no")]
|
||||
None = 1 << 0,
|
||||
|
||||
[Mapping("good")]
|
||||
Good = 1 << 1,
|
||||
|
||||
[Mapping("baddump")]
|
||||
BadDump = 1 << 2,
|
||||
|
||||
[Mapping("nodump", "yes")]
|
||||
Nodump = 1 << 3,
|
||||
|
||||
[Mapping("verified")]
|
||||
Verified = 1 << 4,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine what type of file an item is
|
||||
/// </summary>
|
||||
@@ -347,341 +53,157 @@ namespace SabreTools.Metadata.DatItems
|
||||
|
||||
// "Actionable" item types
|
||||
|
||||
[Mapping("rom")]
|
||||
/// <summary>"rom"</summary>
|
||||
Rom,
|
||||
|
||||
[Mapping("disk")]
|
||||
/// <summary>"disk"</summary>
|
||||
Disk,
|
||||
|
||||
[Mapping("file")]
|
||||
/// <summary>"file"</summary>
|
||||
File,
|
||||
|
||||
[Mapping("media")]
|
||||
/// <summary>"media"</summary>
|
||||
Media,
|
||||
|
||||
// "Auxiliary" item types
|
||||
|
||||
[Mapping("adjuster")]
|
||||
/// <summary>"adjuster"</summary>
|
||||
Adjuster,
|
||||
|
||||
[Mapping("analog")]
|
||||
/// <summary>"analog"</summary>
|
||||
Analog,
|
||||
|
||||
[Mapping("archive")]
|
||||
/// <summary>"archive"</summary>
|
||||
Archive,
|
||||
|
||||
[Mapping("biosset")]
|
||||
/// <summary>"biosset"</summary>
|
||||
BiosSet,
|
||||
|
||||
[Mapping("chip")]
|
||||
/// <summary>"chip"</summary>
|
||||
Chip,
|
||||
|
||||
[Mapping("condition")]
|
||||
/// <summary>"condition"</summary>
|
||||
Condition,
|
||||
|
||||
[Mapping("configuration")]
|
||||
/// <summary>"configuration"</summary>
|
||||
Configuration,
|
||||
|
||||
[Mapping("conflocation")]
|
||||
/// <summary>"conflocation"</summary>
|
||||
ConfLocation,
|
||||
|
||||
[Mapping("confsetting")]
|
||||
/// <summary>"confsetting"</summary>
|
||||
ConfSetting,
|
||||
|
||||
[Mapping("control")]
|
||||
/// <summary>"control"</summary>
|
||||
Control,
|
||||
|
||||
[Mapping("dataarea")]
|
||||
/// <summary>"dataarea"</summary>
|
||||
DataArea,
|
||||
|
||||
[Mapping("device")]
|
||||
/// <summary>"device"</summary>
|
||||
Device,
|
||||
|
||||
[Mapping("device_ref", "deviceref")]
|
||||
/// <summary>"device_ref", "deviceref"</summary>
|
||||
DeviceRef,
|
||||
|
||||
[Mapping("diplocation")]
|
||||
/// <summary>"diplocation"</summary>
|
||||
DipLocation,
|
||||
|
||||
[Mapping("dipswitch")]
|
||||
/// <summary>"dipswitch"</summary>
|
||||
DipSwitch,
|
||||
|
||||
[Mapping("dipvalue")]
|
||||
/// <summary>"dipvalue"</summary>
|
||||
DipValue,
|
||||
|
||||
[Mapping("diskarea")]
|
||||
/// <summary>"diskarea"</summary>
|
||||
DiskArea,
|
||||
|
||||
[Mapping("display")]
|
||||
/// <summary>"display"</summary>
|
||||
Display,
|
||||
|
||||
[Mapping("driver")]
|
||||
/// <summary>"driver"</summary>
|
||||
Driver,
|
||||
|
||||
[Mapping("extension")]
|
||||
/// <summary>"extension"</summary>
|
||||
Extension,
|
||||
|
||||
[Mapping("feature")]
|
||||
/// <summary>"feature"</summary>
|
||||
Feature,
|
||||
|
||||
[Mapping("info")]
|
||||
/// <summary>"info"</summary>
|
||||
Info,
|
||||
|
||||
[Mapping("input")]
|
||||
/// <summary>"input"</summary>
|
||||
Input,
|
||||
|
||||
[Mapping("instance")]
|
||||
/// <summary>"instance"</summary>
|
||||
Instance,
|
||||
|
||||
[Mapping("original")]
|
||||
/// <summary>"original"</summary>
|
||||
Original,
|
||||
|
||||
[Mapping("part")]
|
||||
/// <summary>"part"</summary>
|
||||
Part,
|
||||
|
||||
[Mapping("part_feature", "partfeature")]
|
||||
/// <summary>"part_feature", "partfeature"</summary>
|
||||
PartFeature,
|
||||
|
||||
[Mapping("port")]
|
||||
/// <summary>"port"</summary>
|
||||
Port,
|
||||
|
||||
[Mapping("ramoption", "ram_option")]
|
||||
/// <summary>"ramoption", "ram_option"</summary>
|
||||
RamOption,
|
||||
|
||||
[Mapping("release")]
|
||||
/// <summary>"release"</summary>
|
||||
Release,
|
||||
|
||||
[Mapping("release_details", "releasedetails")]
|
||||
/// <summary>"release_details", "releasedetails"</summary>
|
||||
ReleaseDetails,
|
||||
|
||||
[Mapping("sample")]
|
||||
/// <summary>"sample"</summary>
|
||||
Sample,
|
||||
|
||||
[Mapping("serials")]
|
||||
/// <summary>"serials"</summary>
|
||||
Serials,
|
||||
|
||||
[Mapping("sharedfeat", "shared_feat", "sharedfeature", "shared_feature")]
|
||||
/// <summary>"sharedfeat", "shared_feat", "sharedfeature", "shared_feature"</summary>
|
||||
SharedFeat,
|
||||
|
||||
[Mapping("slot")]
|
||||
/// <summary>"slot"</summary>
|
||||
Slot,
|
||||
|
||||
[Mapping("slotoption", "slot_option")]
|
||||
/// <summary>"slotoption", "slot_option"</summary>
|
||||
SlotOption,
|
||||
|
||||
[Mapping("softwarelist", "software_list")]
|
||||
/// <summary>"softwarelist", "software_list"</summary>
|
||||
SoftwareList,
|
||||
|
||||
[Mapping("sound")]
|
||||
/// <summary>"sound"</summary>
|
||||
Sound,
|
||||
|
||||
[Mapping("source_details", "sourcedetails")]
|
||||
/// <summary>"source_details", "sourcedetails"</summary>
|
||||
SourceDetails,
|
||||
|
||||
[Mapping("blank")]
|
||||
/// <summary>"blank"</summary>
|
||||
Blank = 99, // This is not a real type, only used internally
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the loadflag value
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum LoadFlag
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
[Mapping("load16_byte")]
|
||||
Load16Byte = 1 << 0,
|
||||
|
||||
[Mapping("load16_word")]
|
||||
Load16Word = 1 << 1,
|
||||
|
||||
[Mapping("load16_word_swap")]
|
||||
Load16WordSwap = 1 << 2,
|
||||
|
||||
[Mapping("load32_byte")]
|
||||
Load32Byte = 1 << 3,
|
||||
|
||||
[Mapping("load32_word")]
|
||||
Load32Word = 1 << 4,
|
||||
|
||||
[Mapping("load32_word_swap")]
|
||||
Load32WordSwap = 1 << 5,
|
||||
|
||||
[Mapping("load32_dword")]
|
||||
Load32DWord = 1 << 6,
|
||||
|
||||
[Mapping("load64_word")]
|
||||
Load64Word = 1 << 7,
|
||||
|
||||
[Mapping("load64_word_swap")]
|
||||
Load64WordSwap = 1 << 8,
|
||||
|
||||
[Mapping("reload")]
|
||||
Reload = 1 << 9,
|
||||
|
||||
[Mapping("fill")]
|
||||
Fill = 1 << 10,
|
||||
|
||||
[Mapping("continue")]
|
||||
Continue = 1 << 11,
|
||||
|
||||
[Mapping("reload_plain")]
|
||||
ReloadPlain = 1 << 12,
|
||||
|
||||
[Mapping("ignore")]
|
||||
Ignore = 1 << 13,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine what type of machine it is
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum MachineType
|
||||
{
|
||||
[Mapping("none")]
|
||||
/// <summary>"none"</summary>
|
||||
None = 0,
|
||||
|
||||
[Mapping("bios")]
|
||||
/// <summary>"bios"</summary>
|
||||
Bios = 1 << 0,
|
||||
|
||||
[Mapping("device", "dev")]
|
||||
/// <summary>"device", "dev"</summary>
|
||||
Device = 1 << 1,
|
||||
|
||||
[Mapping("mechanical", "mech")]
|
||||
/// <summary>"mechanical", "mech"</summary>
|
||||
Mechanical = 1 << 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine which OpenMSX subtype an item is
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum OpenMSXSubType
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
[Mapping("rom")]
|
||||
Rom = 1 << 0,
|
||||
|
||||
[Mapping("megarom")]
|
||||
MegaRom = 1 << 1,
|
||||
|
||||
[Mapping("sccpluscart")]
|
||||
SCCPlusCart = 1 << 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine relation of value to condition
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum Relation
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
[Mapping("eq")]
|
||||
Equal = 1 << 0,
|
||||
|
||||
[Mapping("ne")]
|
||||
NotEqual = 1 << 1,
|
||||
|
||||
[Mapping("gt")]
|
||||
GreaterThan = 1 << 2,
|
||||
|
||||
[Mapping("le")]
|
||||
LessThanOrEqual = 1 << 3,
|
||||
|
||||
[Mapping("lt")]
|
||||
LessThan = 1 << 4,
|
||||
|
||||
[Mapping("ge")]
|
||||
GreaterThanOrEqual = 1 << 5,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine machine runnable status
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum Runnable
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
[Mapping("no")]
|
||||
No = 1 << 0,
|
||||
|
||||
[Mapping("partial")]
|
||||
Partial = 1 << 1,
|
||||
|
||||
[Mapping("yes")]
|
||||
Yes = 1 << 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine software list status
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum SoftwareListStatus
|
||||
{
|
||||
[Mapping("none")]
|
||||
None = 0,
|
||||
|
||||
[Mapping("original")]
|
||||
Original = 1 << 0,
|
||||
|
||||
[Mapping("compatible")]
|
||||
Compatible = 1 << 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine machine support status
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum Supported
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
[Mapping("no", "unsupported")]
|
||||
No = 1 << 0,
|
||||
|
||||
[Mapping("partial")]
|
||||
Partial = 1 << 1,
|
||||
|
||||
[Mapping("yes", "supported")]
|
||||
Yes = 1 << 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine driver support statuses
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum SupportStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
[Mapping("good")]
|
||||
Good = 1 << 0,
|
||||
|
||||
[Mapping("imperfect")]
|
||||
Imperfect = 1 << 1,
|
||||
|
||||
[Mapping("preliminary")]
|
||||
Preliminary = 1 << 2,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,345 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
#region Private Maps
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for ChipType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, ChipType> _toChipTypeMap = Converters.GenerateToEnum<ChipType>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for ChipType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<ChipType, string> _fromChipTypeMap = Converters.GenerateToString<ChipType>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for ControlType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, ControlType> _toControlTypeMap = Converters.GenerateToEnum<ControlType>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for ControlType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<ControlType, string> _fromControlTypeMap = Converters.GenerateToString<ControlType>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for DeviceType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, DeviceType> _toDeviceTypeMap = Converters.GenerateToEnum<DeviceType>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for DeviceType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<DeviceType, string> _fromDeviceTypeMap = Converters.GenerateToString<DeviceType>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for DisplayType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, DisplayType> _toDisplayTypeMap = Converters.GenerateToEnum<DisplayType>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for DisplayType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<DisplayType, string> _fromDisplayTypeMap = Converters.GenerateToString<DisplayType>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for Endianness
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, Endianness> _toEndiannessMap = Converters.GenerateToEnum<Endianness>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for Endianness
|
||||
/// </summary>
|
||||
private static readonly Dictionary<Endianness, string> _fromEndiannessMap = Converters.GenerateToString<Endianness>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for FeatureStatus
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, FeatureStatus> _toFeatureStatusMap = Converters.GenerateToEnum<FeatureStatus>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for FeatureStatus
|
||||
/// </summary>
|
||||
private static readonly Dictionary<FeatureStatus, string> _fromFeatureStatusMap = Converters.GenerateToString<FeatureStatus>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for FeatureType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, FeatureType> _toFeatureTypeMap = Converters.GenerateToEnum<FeatureType>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for FeatureType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<FeatureType, string> _fromFeatureTypeMap = Converters.GenerateToString<FeatureType>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for ItemStatus
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, ItemStatus> _toItemStatusMap = Converters.GenerateToEnum<ItemStatus>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for ItemStatus
|
||||
/// </summary>
|
||||
private static readonly Dictionary<ItemStatus, string> _fromItemStatusMap = Converters.GenerateToString<ItemStatus>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for ItemType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, ItemType> _toItemTypeMap = Converters.GenerateToEnum<ItemType>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for ItemType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<ItemType, string> _fromItemTypeMap = Converters.GenerateToString<ItemType>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for LoadFlag
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, LoadFlag> _toLoadFlagMap = Converters.GenerateToEnum<LoadFlag>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for LoadFlag
|
||||
/// </summary>
|
||||
private static readonly Dictionary<LoadFlag, string> _fromLoadFlagMap = Converters.GenerateToString<LoadFlag>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for MachineType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, MachineType> _toMachineTypeMap = Converters.GenerateToEnum<MachineType>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for OpenMSXSubType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, OpenMSXSubType> _toOpenMSXSubTypeMap = Converters.GenerateToEnum<OpenMSXSubType>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for OpenMSXSubType
|
||||
/// </summary>
|
||||
private static readonly Dictionary<OpenMSXSubType, string> _fromOpenMSXSubTypeMap = Converters.GenerateToString<OpenMSXSubType>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for Relation
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, Relation> _toRelationMap = Converters.GenerateToEnum<Relation>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for Relation
|
||||
/// </summary>
|
||||
private static readonly Dictionary<Relation, string> _fromRelationMap = Converters.GenerateToString<Relation>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for Runnable
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, Runnable> _toRunnableMap = Converters.GenerateToEnum<Runnable>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for Runnable
|
||||
/// </summary>
|
||||
private static readonly Dictionary<Runnable, string> _fromRunnableMap = Converters.GenerateToString<Runnable>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for SoftwareListStatus
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, SoftwareListStatus> _toSoftwareListStatusMap = Converters.GenerateToEnum<SoftwareListStatus>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for SoftwareListStatus
|
||||
/// </summary>
|
||||
private static readonly Dictionary<SoftwareListStatus, string> _fromSoftwareListStatusMap = Converters.GenerateToString<SoftwareListStatus>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for Supported
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, Supported> _toSupportedMap = Converters.GenerateToEnum<Supported>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for Supported
|
||||
/// </summary>
|
||||
private static readonly Dictionary<Supported, string> _fromSupportedMap = Converters.GenerateToString<Supported>(useSecond: false);
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for Supported (secondary)
|
||||
/// </summary>
|
||||
private static readonly Dictionary<Supported, string> _fromSupportedSecondaryMap = Converters.GenerateToString<Supported>(useSecond: true);
|
||||
|
||||
/// <summary>
|
||||
/// Set of enum to string mappings for SupportStatus
|
||||
/// </summary>
|
||||
private static readonly Dictionary<string, SupportStatus> _toSupportStatusMap = Converters.GenerateToEnum<SupportStatus>();
|
||||
|
||||
/// <summary>
|
||||
/// Set of string to enum mappings for SupportStatus
|
||||
/// </summary>
|
||||
private static readonly Dictionary<SupportStatus, string> _fromSupportStatusMap = Converters.GenerateToString<SupportStatus>(useSecond: false);
|
||||
|
||||
#endregion
|
||||
|
||||
#region String to Enum
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static ChipType AsChipType(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toChipTypeMap.ContainsKey(value))
|
||||
return _toChipTypeMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static ControlType AsControlType(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toControlTypeMap.ContainsKey(value))
|
||||
return _toControlTypeMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static DeviceType AsDeviceType(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toDeviceTypeMap.ContainsKey(value))
|
||||
return _toDeviceTypeMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static DisplayType AsDisplayType(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toDisplayTypeMap.ContainsKey(value))
|
||||
return _toDisplayTypeMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static Endianness AsEndianness(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toEndiannessMap.ContainsKey(value))
|
||||
return _toEndiannessMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static FeatureStatus AsFeatureStatus(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toFeatureStatusMap.ContainsKey(value))
|
||||
return _toFeatureStatusMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static FeatureType AsFeatureType(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toFeatureTypeMap.ContainsKey(value))
|
||||
return _toFeatureTypeMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static ItemStatus AsItemStatus(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toItemStatusMap.ContainsKey(value))
|
||||
return _toItemStatusMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
@@ -347,37 +11,57 @@ namespace SabreTools.Metadata.DatItems
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static ItemType AsItemType(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
// "Actionable" item types
|
||||
"rom" => ItemType.Rom,
|
||||
"disk" => ItemType.Disk,
|
||||
"file" => ItemType.File,
|
||||
"media" => ItemType.Media,
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toItemTypeMap.ContainsKey(value))
|
||||
return _toItemTypeMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static LoadFlag AsLoadFlag(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toLoadFlagMap.ContainsKey(value))
|
||||
return _toLoadFlagMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
// "Auxiliary" item types
|
||||
"adjuster" => ItemType.Adjuster,
|
||||
"analog" => ItemType.Analog,
|
||||
"archive" => ItemType.Archive,
|
||||
"biosset" => ItemType.BiosSet,
|
||||
"chip" => ItemType.Chip,
|
||||
"condition" => ItemType.Condition,
|
||||
"configuration" => ItemType.Configuration,
|
||||
"conflocation" => ItemType.ConfLocation,
|
||||
"confsetting" => ItemType.ConfSetting,
|
||||
"control" => ItemType.Control,
|
||||
"dataarea" => ItemType.DataArea,
|
||||
"device" => ItemType.Device,
|
||||
"device_ref" or "deviceref" => ItemType.DeviceRef,
|
||||
"diplocation" => ItemType.DipLocation,
|
||||
"dipswitch" => ItemType.DipSwitch,
|
||||
"dipvalue" => ItemType.DipValue,
|
||||
"diskarea" => ItemType.DiskArea,
|
||||
"display" => ItemType.Display,
|
||||
"driver" => ItemType.Driver,
|
||||
"extension" => ItemType.Extension,
|
||||
"feature" => ItemType.Feature,
|
||||
"info" => ItemType.Info,
|
||||
"input" => ItemType.Input,
|
||||
"instance" => ItemType.Instance,
|
||||
"original" => ItemType.Original,
|
||||
"part" => ItemType.Part,
|
||||
"part_feature" or "partfeature" => ItemType.PartFeature,
|
||||
"port" => ItemType.Port,
|
||||
"ramoption" or "ram_option" => ItemType.RamOption,
|
||||
"release" => ItemType.Release,
|
||||
"release_details" or "releasedetails" => ItemType.ReleaseDetails,
|
||||
"sample" => ItemType.Sample,
|
||||
"serials" => ItemType.Serials,
|
||||
"sharedfeat" or "shared_feat" or "sharedfeature" or "shared_feature" => ItemType.SharedFeat,
|
||||
"slot" => ItemType.Slot,
|
||||
"slotoption" or "slot_option" => ItemType.SlotOption,
|
||||
"softwarelist" or "software_list" => ItemType.SoftwareList,
|
||||
"sound" => ItemType.Sound,
|
||||
"source_details" or "sourcedetails" => ItemType.SourceDetails,
|
||||
"blank" => ItemType.Blank,
|
||||
_ => ItemType.NULL,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -387,137 +71,14 @@ namespace SabreTools.Metadata.DatItems
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static MachineType AsMachineType(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toMachineTypeMap.ContainsKey(value))
|
||||
return _toMachineTypeMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static OpenMSXSubType AsOpenMSXSubType(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toOpenMSXSubTypeMap.ContainsKey(value))
|
||||
return _toOpenMSXSubTypeMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static Relation AsRelation(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toRelationMap.ContainsKey(value))
|
||||
return _toRelationMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static Runnable AsRunnable(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toRunnableMap.ContainsKey(value))
|
||||
return _toRunnableMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static SoftwareListStatus AsSoftwareListStatus(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toSoftwareListStatusMap.ContainsKey(value))
|
||||
return _toSoftwareListStatusMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static Supported AsSupported(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toSupportedMap.ContainsKey(value))
|
||||
return _toSupportedMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the enum value for an input string, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">String value to parse/param>
|
||||
/// <returns>Enum value representing the input, default on error</returns>
|
||||
public static SupportStatus AsSupportStatus(this string? value)
|
||||
{
|
||||
// Normalize the input value
|
||||
value = value?.ToLowerInvariant();
|
||||
if (value is null)
|
||||
return default;
|
||||
|
||||
// Try to get the value from the mappings
|
||||
if (_toSupportStatusMap.ContainsKey(value))
|
||||
return _toSupportStatusMap[value];
|
||||
|
||||
// Otherwise, return the default value for the enum
|
||||
return default;
|
||||
return value?.ToLowerInvariant() switch
|
||||
{
|
||||
"none" => MachineType.None,
|
||||
"bios" => MachineType.Bios,
|
||||
"device" or "dev" => MachineType.Device,
|
||||
"mechanical" or "mech" => MachineType.Mechanical,
|
||||
_ => MachineType.None,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -528,258 +89,63 @@ namespace SabreTools.Metadata.DatItems
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this ChipType value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromChipTypeMap.ContainsKey(value))
|
||||
return _fromChipTypeMap[value];
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this ControlType value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromControlTypeMap.ContainsKey(value))
|
||||
return _fromControlTypeMap[value];
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this DeviceType value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromDeviceTypeMap.ContainsKey(value))
|
||||
return _fromDeviceTypeMap[value];
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this DisplayType value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromDisplayTypeMap.ContainsKey(value))
|
||||
return _fromDisplayTypeMap[value];
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this Endianness value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromEndiannessMap.ContainsKey(value))
|
||||
return _fromEndiannessMap[value];
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this FeatureStatus value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromFeatureStatusMap.ContainsKey(value))
|
||||
return _fromFeatureStatusMap[value];
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this FeatureType value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromFeatureTypeMap.ContainsKey(value))
|
||||
return _fromFeatureTypeMap[value];
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this ItemStatus value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromItemStatusMap.ContainsKey(value))
|
||||
return _fromItemStatusMap[value];
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this ItemType value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromItemTypeMap.ContainsKey(value))
|
||||
return _fromItemTypeMap[value];
|
||||
return value switch
|
||||
{
|
||||
// "Actionable" item types
|
||||
ItemType.Rom => "rom",
|
||||
ItemType.Disk => "disk",
|
||||
ItemType.File => "file",
|
||||
ItemType.Media => "media",
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
// "Auxiliary" item types
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this LoadFlag value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromLoadFlagMap.ContainsKey(value))
|
||||
return _fromLoadFlagMap[value];
|
||||
ItemType.Adjuster => "adjuster",
|
||||
ItemType.Analog => "analog",
|
||||
ItemType.Archive => "archive",
|
||||
ItemType.BiosSet => "biosset",
|
||||
ItemType.Chip => "chip",
|
||||
ItemType.Condition => "condition",
|
||||
ItemType.Configuration => "configuration",
|
||||
ItemType.ConfLocation => "conflocation",
|
||||
ItemType.ConfSetting => "confsetting",
|
||||
ItemType.Control => "control",
|
||||
ItemType.DataArea => "dataarea",
|
||||
ItemType.Device => "device",
|
||||
ItemType.DeviceRef => "device_ref",
|
||||
ItemType.DipLocation => "diplocation",
|
||||
ItemType.DipSwitch => "dipswitch",
|
||||
ItemType.DipValue => "dipvalue",
|
||||
ItemType.DiskArea => "diskarea",
|
||||
ItemType.Display => "display",
|
||||
ItemType.Driver => "driver",
|
||||
ItemType.Extension => "extension",
|
||||
ItemType.Feature => "feature",
|
||||
ItemType.Info => "info",
|
||||
ItemType.Input => "input",
|
||||
ItemType.Instance => "instance",
|
||||
ItemType.Original => "original",
|
||||
ItemType.Part => "part",
|
||||
ItemType.PartFeature => "part_feature",
|
||||
ItemType.Port => "port",
|
||||
ItemType.RamOption => "ramoption",
|
||||
ItemType.Release => "release",
|
||||
ItemType.ReleaseDetails => "release_details",
|
||||
ItemType.Sample => "sample",
|
||||
ItemType.Serials => "serials",
|
||||
ItemType.SharedFeat => "sharedfeat",
|
||||
ItemType.Slot => "slot",
|
||||
ItemType.SlotOption => "slotoption",
|
||||
ItemType.SoftwareList => "softwarelist",
|
||||
ItemType.Sound => "sound",
|
||||
ItemType.SourceDetails => "source_details",
|
||||
ItemType.Blank => "blank",
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this OpenMSXSubType value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromOpenMSXSubTypeMap.ContainsKey(value))
|
||||
return _fromOpenMSXSubTypeMap[value];
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this Relation value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromRelationMap.ContainsKey(value))
|
||||
return _fromRelationMap[value];
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this Runnable value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromRunnableMap.ContainsKey(value))
|
||||
return _fromRunnableMap[value];
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this SoftwareListStatus value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromSoftwareListStatusMap.ContainsKey(value))
|
||||
return _fromSoftwareListStatusMap[value];
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this Supported value, bool useSecond = false)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (!useSecond && _fromSupportedMap.ContainsKey(value))
|
||||
return _fromSupportedMap[value];
|
||||
else if (useSecond && _fromSupportedSecondaryMap.ContainsKey(value))
|
||||
return _fromSupportedSecondaryMap[value];
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the string value for an input enum, if possible
|
||||
/// </summary>
|
||||
/// <param name="value">Enum value to parse/param>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <returns>String value representing the input, default on error</returns>
|
||||
public static string? AsStringValue(this SupportStatus value)
|
||||
{
|
||||
// Try to get the value from the mappings
|
||||
if (_fromSupportStatusMap.ContainsKey(value))
|
||||
return _fromSupportStatusMap[value];
|
||||
|
||||
// Otherwise, return null
|
||||
return null;
|
||||
ItemType.NULL => null,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Data.Extensions;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
@@ -29,7 +30,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
string? chipType = ReadString(Data.Models.Metadata.Chip.ChipTypeKey);
|
||||
if (chipType is not null)
|
||||
Write<string?>(Data.Models.Metadata.Chip.ChipTypeKey, chipType.AsChipType().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Chip.ChipTypeKey, chipType.AsChipType()?.AsStringValue());
|
||||
}
|
||||
|
||||
public Chip(Data.Models.Metadata.Chip item, Machine machine, Source source) : this(item)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Data.Extensions;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
@@ -25,7 +26,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
// Process flag values
|
||||
string? condition = ReadString(Data.Models.Metadata.Condition.RelationKey);
|
||||
if (condition is not null)
|
||||
Write<string?>(Data.Models.Metadata.Condition.RelationKey, condition.AsRelation().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Condition.RelationKey, condition.AsRelation()?.AsStringValue());
|
||||
}
|
||||
|
||||
public Condition(Data.Models.Metadata.Condition item, Machine machine, Source source) : this(item)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Data.Extensions;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
@@ -57,7 +58,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
string? controlType = ReadString(Data.Models.Metadata.Control.ControlTypeKey);
|
||||
if (controlType is not null)
|
||||
Write<string?>(Data.Models.Metadata.Control.ControlTypeKey, controlType.AsControlType().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Control.ControlTypeKey, controlType.AsControlType()?.AsStringValue());
|
||||
}
|
||||
|
||||
public Control(Data.Models.Metadata.Control item, Machine machine, Source source) : this(item)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Data.Extensions;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
// Process flag values
|
||||
string? endianness = ReadString(Data.Models.Metadata.DataArea.EndiannessKey);
|
||||
if (endianness is not null)
|
||||
Write<string?>(Data.Models.Metadata.DataArea.EndiannessKey, endianness.AsEndianness().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.DataArea.EndiannessKey, endianness.AsEndianness()?.AsStringValue());
|
||||
|
||||
long? size = ReadLong(Data.Models.Metadata.DataArea.SizeKey);
|
||||
if (size is not null)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Data.Extensions;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
@@ -50,7 +51,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
string? deviceType = ReadString(Data.Models.Metadata.Device.DeviceTypeKey);
|
||||
if (deviceType is not null)
|
||||
Write<string?>(Data.Models.Metadata.Device.DeviceTypeKey, deviceType.AsDeviceType().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Device.DeviceTypeKey, deviceType.AsDeviceType()?.AsStringValue());
|
||||
|
||||
// Handle subitems
|
||||
var instance = item.Read<Data.Models.Metadata.Instance>(Data.Models.Metadata.Device.InstanceKey);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Data.Extensions;
|
||||
using SabreTools.Data.Models.Metadata;
|
||||
using SabreTools.Text.Extensions;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
@@ -73,7 +74,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
string? status = ReadString(Data.Models.Metadata.Disk.StatusKey);
|
||||
if (status is not null)
|
||||
Write<string?>(Data.Models.Metadata.Disk.StatusKey, status.AsItemStatus().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Disk.StatusKey, status.AsItemStatus()?.AsStringValue());
|
||||
|
||||
bool? writable = ReadBool(Data.Models.Metadata.Disk.WritableKey);
|
||||
if (writable is not null)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Data.Extensions;
|
||||
using SabreTools.Text.Extensions;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
@@ -58,7 +59,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
string? displayType = ReadString(Data.Models.Metadata.Display.DisplayTypeKey);
|
||||
if (displayType is not null)
|
||||
Write<string?>(Data.Models.Metadata.Display.DisplayTypeKey, displayType.AsDisplayType().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Display.DisplayTypeKey, displayType.AsDisplayType()?.AsStringValue());
|
||||
|
||||
long? vbEnd = ReadLong(Data.Models.Metadata.Display.VBEndKey);
|
||||
if (vbEnd is not null)
|
||||
@@ -88,7 +89,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
// TODO: Convert this block to more traditional set of if/then
|
||||
Write(Data.Models.Metadata.Video.AspectXKey, NumberHelper.ConvertToInt64(item.ReadString(Data.Models.Metadata.Video.AspectXKey)));
|
||||
Write(Data.Models.Metadata.Video.AspectYKey, NumberHelper.ConvertToInt64(item.ReadString(Data.Models.Metadata.Video.AspectYKey)));
|
||||
Write<string?>(Data.Models.Metadata.Display.DisplayTypeKey, item.ReadString(Data.Models.Metadata.Video.ScreenKey).AsDisplayType().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Display.DisplayTypeKey, item.ReadString(Data.Models.Metadata.Video.ScreenKey).AsDisplayType()?.AsStringValue());
|
||||
Write(Data.Models.Metadata.Display.HeightKey, NumberHelper.ConvertToInt64(item.ReadString(Data.Models.Metadata.Video.HeightKey)));
|
||||
Write(Data.Models.Metadata.Display.RefreshKey, NumberHelper.ConvertToDouble(item.ReadString(Data.Models.Metadata.Video.RefreshKey)));
|
||||
Write(Data.Models.Metadata.Display.WidthKey, NumberHelper.ConvertToInt64(item.ReadString(Data.Models.Metadata.Video.WidthKey)));
|
||||
@@ -125,7 +126,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
string? screen = ReadString(Data.Models.Metadata.Video.ScreenKey);
|
||||
if (screen is not null)
|
||||
Write<string?>(Data.Models.Metadata.Display.DisplayTypeKey, screen.AsDisplayType().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Display.DisplayTypeKey, screen.AsDisplayType()?.AsStringValue());
|
||||
|
||||
long? width = ReadLong(Data.Models.Metadata.Video.WidthKey);
|
||||
if (width is not null)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Data.Extensions;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
@@ -25,15 +26,15 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
// Process flag values
|
||||
string? cocktail = ReadString(Data.Models.Metadata.Driver.CocktailKey);
|
||||
if (cocktail is not null)
|
||||
Write<string?>(Data.Models.Metadata.Driver.CocktailKey, cocktail.AsSupportStatus().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Driver.CocktailKey, cocktail.AsSupportStatus()?.AsStringValue());
|
||||
|
||||
string? color = ReadString(Data.Models.Metadata.Driver.ColorKey);
|
||||
if (color is not null)
|
||||
Write<string?>(Data.Models.Metadata.Driver.ColorKey, color.AsSupportStatus().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Driver.ColorKey, color.AsSupportStatus()?.AsStringValue());
|
||||
|
||||
string? emulation = ReadString(Data.Models.Metadata.Driver.EmulationKey);
|
||||
if (emulation is not null)
|
||||
Write<string?>(Data.Models.Metadata.Driver.EmulationKey, emulation.AsSupportStatus().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Driver.EmulationKey, emulation.AsSupportStatus()?.AsStringValue());
|
||||
|
||||
bool? incomplete = ReadBool(Data.Models.Metadata.Driver.IncompleteKey);
|
||||
if (incomplete is not null)
|
||||
@@ -53,15 +54,15 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
string? saveState = ReadString(Data.Models.Metadata.Driver.SaveStateKey);
|
||||
if (saveState is not null)
|
||||
Write<string?>(Data.Models.Metadata.Driver.SaveStateKey, saveState.AsSupported().AsStringValue(useSecond: true));
|
||||
Write<string?>(Data.Models.Metadata.Driver.SaveStateKey, saveState.AsSupported()?.AsStringValue(useSecond: true));
|
||||
|
||||
string? sound = ReadString(Data.Models.Metadata.Driver.SoundKey);
|
||||
if (sound is not null)
|
||||
Write<string?>(Data.Models.Metadata.Driver.SoundKey, sound.AsSupportStatus().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Driver.SoundKey, sound.AsSupportStatus()?.AsStringValue());
|
||||
|
||||
string? status = ReadString(Data.Models.Metadata.Driver.StatusKey);
|
||||
if (status is not null)
|
||||
Write<string?>(Data.Models.Metadata.Driver.StatusKey, status.AsSupportStatus().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Driver.StatusKey, status.AsSupportStatus()?.AsStringValue());
|
||||
|
||||
bool? unofficial = ReadBool(Data.Models.Metadata.Driver.UnofficialKey);
|
||||
if (unofficial is not null)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Data.Extensions;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
@@ -25,15 +26,15 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
// Process flag values
|
||||
string? overall = ReadString(Data.Models.Metadata.Feature.OverallKey);
|
||||
if (overall is not null)
|
||||
Write<string?>(Data.Models.Metadata.Feature.OverallKey, overall.AsFeatureStatus().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Feature.OverallKey, overall.AsFeatureStatus()?.AsStringValue());
|
||||
|
||||
string? status = ReadString(Data.Models.Metadata.Feature.StatusKey);
|
||||
if (status is not null)
|
||||
Write<string?>(Data.Models.Metadata.Feature.StatusKey, status.AsFeatureStatus().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Feature.StatusKey, status.AsFeatureStatus()?.AsStringValue());
|
||||
|
||||
string? featureType = ReadString(Data.Models.Metadata.Feature.FeatureTypeKey);
|
||||
if (featureType is not null)
|
||||
Write<string?>(Data.Models.Metadata.Feature.FeatureTypeKey, featureType.AsFeatureType().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Feature.FeatureTypeKey, featureType.AsFeatureType()?.AsStringValue());
|
||||
}
|
||||
|
||||
public Feature(Data.Models.Metadata.Feature item, Machine machine, Source source) : this(item)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Data.Extensions;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
@@ -34,15 +35,15 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
// Process flag values
|
||||
string? overall = ReadString(Data.Models.Metadata.Feature.OverallKey);
|
||||
if (overall is not null)
|
||||
Write<string?>(Data.Models.Metadata.Feature.OverallKey, overall.AsFeatureStatus().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Feature.OverallKey, overall.AsFeatureStatus()?.AsStringValue());
|
||||
|
||||
string? status = ReadString(Data.Models.Metadata.Feature.StatusKey);
|
||||
if (status is not null)
|
||||
Write<string?>(Data.Models.Metadata.Feature.StatusKey, status.AsFeatureStatus().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Feature.StatusKey, status.AsFeatureStatus()?.AsStringValue());
|
||||
|
||||
string? featureType = ReadString(Data.Models.Metadata.Feature.FeatureTypeKey);
|
||||
if (featureType is not null)
|
||||
Write<string?>(Data.Models.Metadata.Feature.FeatureTypeKey, featureType.AsFeatureType().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Feature.FeatureTypeKey, featureType.AsFeatureType()?.AsStringValue());
|
||||
}
|
||||
|
||||
public PartFeature(Data.Models.Metadata.Feature item, Machine machine, Source source) : this(item)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Data.Extensions;
|
||||
using SabreTools.Data.Models.Metadata;
|
||||
using SabreTools.Text.Extensions;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
@@ -36,7 +37,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
get
|
||||
{
|
||||
var status = ReadString(Data.Models.Metadata.Rom.StatusKey).AsItemStatus();
|
||||
return status != ItemStatus.NULL && status != ItemStatus.None;
|
||||
return status is not null && status != ItemStatus.None;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
&& (!string.IsNullOrEmpty(dataArea.GetName())
|
||||
|| dataArea.ReadLong(Data.Models.Metadata.DataArea.SizeKey) is not null
|
||||
|| dataArea.ReadLong(Data.Models.Metadata.DataArea.WidthKey) is not null
|
||||
|| dataArea.ReadString(Data.Models.Metadata.DataArea.EndiannessKey).AsEndianness() != Endianness.NULL);
|
||||
|| dataArea.ReadString(Data.Models.Metadata.DataArea.EndiannessKey).AsEndianness() is not null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,25 +87,25 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
Write<string?>(Data.Models.Metadata.Rom.StatusKey, ItemStatus.None.AsStringValue());
|
||||
}
|
||||
|
||||
public Rom(Data.Models.Metadata.Dump item, Machine machine, Source source, int index)
|
||||
public Rom(Dump item, Machine machine, Source source, int index)
|
||||
{
|
||||
// If we don't have rom data, we can't do anything
|
||||
Data.Models.Metadata.Rom? rom = null;
|
||||
OpenMSXSubType subType = OpenMSXSubType.NULL;
|
||||
OpenMSXSubType? subType = null;
|
||||
|
||||
if (item.Read<Data.Models.Metadata.Rom>(Data.Models.Metadata.Dump.RomKey) is not null)
|
||||
if (item.Read<Data.Models.Metadata.Rom>(Dump.RomKey) is not null)
|
||||
{
|
||||
rom = item.Read<Data.Models.Metadata.Rom>(Data.Models.Metadata.Dump.RomKey);
|
||||
rom = item.Read<Data.Models.Metadata.Rom>(Dump.RomKey);
|
||||
subType = OpenMSXSubType.Rom;
|
||||
}
|
||||
else if (item.Read<Data.Models.Metadata.Rom>(Data.Models.Metadata.Dump.MegaRomKey) is not null)
|
||||
else if (item.Read<Data.Models.Metadata.Rom>(Dump.MegaRomKey) is not null)
|
||||
{
|
||||
rom = item.Read<Data.Models.Metadata.Rom>(Data.Models.Metadata.Dump.MegaRomKey);
|
||||
rom = item.Read<Data.Models.Metadata.Rom>(Dump.MegaRomKey);
|
||||
subType = OpenMSXSubType.MegaRom;
|
||||
}
|
||||
else if (item.Read<Data.Models.Metadata.Rom>(Data.Models.Metadata.Dump.SCCPlusCartKey) is not null)
|
||||
else if (item.Read<Data.Models.Metadata.Rom>(Dump.SCCPlusCartKey) is not null)
|
||||
{
|
||||
rom = item.Read<Data.Models.Metadata.Rom>(Data.Models.Metadata.Dump.SCCPlusCartKey);
|
||||
rom = item.Read<Data.Models.Metadata.Rom>(Dump.SCCPlusCartKey);
|
||||
subType = OpenMSXSubType.SCCPlusCart;
|
||||
}
|
||||
|
||||
@@ -116,14 +117,14 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
SetName(name);
|
||||
Write<string?>(Data.Models.Metadata.Rom.OffsetKey, rom.ReadString(Data.Models.Metadata.Rom.StartKey));
|
||||
Write<string?>(Data.Models.Metadata.Rom.OpenMSXMediaType, subType.AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Rom.OpenMSXMediaType, subType?.AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Rom.OpenMSXType, rom.ReadString(Data.Models.Metadata.Rom.OpenMSXType) ?? rom.ReadString(Data.Models.Metadata.DatItem.TypeKey));
|
||||
Write<string?>(Data.Models.Metadata.Rom.RemarkKey, rom.ReadString(Data.Models.Metadata.Rom.RemarkKey));
|
||||
Write<string?>(Data.Models.Metadata.Rom.SHA1Key, rom.ReadString(Data.Models.Metadata.Rom.SHA1Key));
|
||||
Write<string?>(Data.Models.Metadata.Rom.StartKey, rom.ReadString(Data.Models.Metadata.Rom.StartKey));
|
||||
Write<Source?>(SourceKey, source);
|
||||
|
||||
var original = item.Read<Data.Models.Metadata.Original>(Data.Models.Metadata.Dump.OriginalKey);
|
||||
var original = item.Read<Data.Models.Metadata.Original>(Dump.OriginalKey);
|
||||
if (original is not null)
|
||||
{
|
||||
Write<Original?>("ORIGINAL", new Original
|
||||
@@ -206,11 +207,11 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
string? loadFlag = ReadString(Data.Models.Metadata.Rom.LoadFlagKey);
|
||||
if (loadFlag is not null)
|
||||
Write<string?>(Data.Models.Metadata.Rom.LoadFlagKey, loadFlag.AsLoadFlag().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Rom.LoadFlagKey, loadFlag.AsLoadFlag()?.AsStringValue());
|
||||
|
||||
string? openMSXMediaType = ReadString(Data.Models.Metadata.Rom.OpenMSXMediaType);
|
||||
if (openMSXMediaType is not null)
|
||||
Write<string?>(Data.Models.Metadata.Rom.OpenMSXMediaType, openMSXMediaType.AsOpenMSXSubType().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Rom.OpenMSXMediaType, openMSXMediaType.AsOpenMSXSubType()?.AsStringValue());
|
||||
|
||||
bool? mia = ReadBool(Data.Models.Metadata.Rom.MIAKey);
|
||||
if (mia is not null)
|
||||
@@ -226,7 +227,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
|
||||
string? status = ReadString(Data.Models.Metadata.Rom.StatusKey);
|
||||
if (status is not null)
|
||||
Write<string?>(Data.Models.Metadata.Rom.StatusKey, status.AsItemStatus().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Rom.StatusKey, status.AsItemStatus()?.AsStringValue());
|
||||
|
||||
// Process hash values
|
||||
long? size = ReadLong(Data.Models.Metadata.Rom.SizeKey);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.Data.Extensions;
|
||||
|
||||
namespace SabreTools.Metadata.DatItems.Formats
|
||||
{
|
||||
@@ -25,7 +26,7 @@ namespace SabreTools.Metadata.DatItems.Formats
|
||||
// Process flag values
|
||||
string? status = ReadString(Data.Models.Metadata.SoftwareList.StatusKey);
|
||||
if (status is not null)
|
||||
Write<string?>(Data.Models.Metadata.SoftwareList.StatusKey, status.AsSoftwareListStatus().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.SoftwareList.StatusKey, status.AsSoftwareListStatus()?.AsStringValue());
|
||||
|
||||
// Handle subitems
|
||||
// TODO: Handle the Software subitem
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace SabreTools.Metadata.DatItems
|
||||
|
||||
string? supported = ReadString(Data.Models.Metadata.Machine.SupportedKey);
|
||||
if (supported is not null)
|
||||
Write<string?>(Data.Models.Metadata.Machine.SupportedKey, supported.AsSupported().AsStringValue());
|
||||
Write<string?>(Data.Models.Metadata.Machine.SupportedKey, supported.AsSupported()?.AsStringValue());
|
||||
|
||||
// Handle Trurip object, if it exists
|
||||
var truripItem = machine.Read<Data.Models.Logiqx.Trurip>(Data.Models.Metadata.Machine.TruripKey);
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SabreTools.Metadata
|
||||
namespace SabreTools.Metadata
|
||||
{
|
||||
public static class Converters
|
||||
{
|
||||
@@ -22,49 +19,6 @@ namespace SabreTools.Metadata
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a set of mappings from strings to enum values
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Enum type that is expected</typeparam>
|
||||
/// <returns>Dictionary of string to enum values</returns>
|
||||
public static Dictionary<string, T> GenerateToEnum<T>()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get all of the values for the enum type
|
||||
var values = Enum.GetValues(typeof(T));
|
||||
|
||||
// Build the output dictionary
|
||||
Dictionary<string, T> mappings = [];
|
||||
foreach (T? value in values)
|
||||
{
|
||||
// If the value is null
|
||||
if (value is null)
|
||||
continue;
|
||||
|
||||
// Try to get the mapping attribute
|
||||
MappingAttribute? attr = GetMappingAttribute(value);
|
||||
if (attr?.Mappings is null || attr.Mappings.Length == 0)
|
||||
continue;
|
||||
|
||||
// Loop through the mappings and add each
|
||||
foreach (string mapString in attr.Mappings)
|
||||
{
|
||||
if (mapString is not null)
|
||||
mappings[mapString] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the output dictionary
|
||||
return mappings;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// This should not happen, only if the type was not an enum
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Enum to String
|
||||
@@ -84,93 +38,6 @@ namespace SabreTools.Metadata
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a set of mappings from enum values to string
|
||||
/// </summary>
|
||||
/// <param name="useSecond">True to use the second mapping option, if it exists</param>
|
||||
/// <typeparam name="T">Enum type that is expected</typeparam>
|
||||
/// <returns>Dictionary of enum to string values</returns>
|
||||
public static Dictionary<T, string> GenerateToString<T>(bool useSecond) where T : notnull
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get all of the values for the enum type
|
||||
var values = Enum.GetValues(typeof(T));
|
||||
|
||||
// Build the output dictionary
|
||||
Dictionary<T, string> mappings = [];
|
||||
foreach (T? value in values)
|
||||
{
|
||||
// If the value is null
|
||||
if (value is null)
|
||||
continue;
|
||||
|
||||
// Try to get the mapping attribute
|
||||
MappingAttribute? attr = GetMappingAttribute(value);
|
||||
if (attr?.Mappings is null || attr.Mappings.Length == 0)
|
||||
continue;
|
||||
|
||||
// Use either the first or second item in the list
|
||||
if (attr.Mappings.Length > 1 && useSecond)
|
||||
mappings[value] = attr.Mappings[1];
|
||||
else
|
||||
mappings[value] = attr.Mappings[0];
|
||||
}
|
||||
|
||||
// Return the output dictionary
|
||||
return mappings;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// This should not happen, only if the type was not an enum
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helpers
|
||||
|
||||
/// <summary>
|
||||
/// Get the MappingAttribute from a supported value
|
||||
/// </summary>
|
||||
/// <param name="value">Value to use</param>
|
||||
/// <returns>MappingAttribute attached to the value</returns>
|
||||
internal static MappingAttribute? GetMappingAttribute<T>(T? value)
|
||||
{
|
||||
// Null value in, null value out
|
||||
if (value is null)
|
||||
return null;
|
||||
|
||||
// Current enumeration type
|
||||
var enumType = typeof(T);
|
||||
if (Nullable.GetUnderlyingType(enumType) is not null)
|
||||
enumType = Nullable.GetUnderlyingType(enumType);
|
||||
|
||||
// If the value returns a null on ToString, just return null
|
||||
string? valueStr = value.ToString();
|
||||
if (string.IsNullOrEmpty(valueStr))
|
||||
return null;
|
||||
|
||||
// Get the member info array
|
||||
var memberInfos = enumType?.GetMember(valueStr);
|
||||
if (memberInfos is null)
|
||||
return null;
|
||||
|
||||
// Get the enum value info from the array, if possible
|
||||
var enumValueMemberInfo = Array.Find(memberInfos, m => m.DeclaringType == enumType);
|
||||
if (enumValueMemberInfo is null)
|
||||
return null;
|
||||
|
||||
// Try to get the relevant attribute
|
||||
var attributes = enumValueMemberInfo.GetCustomAttributes(typeof(MappingAttribute), true);
|
||||
if (attributes is null || attributes.Length == 0)
|
||||
return null;
|
||||
|
||||
// Return the first attribute, if possible
|
||||
return (MappingAttribute?)attributes[0];
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace SabreTools.Metadata
|
||||
{
|
||||
/// <summary>
|
||||
/// Maps a set of strings to an enum value
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
|
||||
public class MappingAttribute(params string[] mappings) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Set of mapping strings
|
||||
/// </summary>
|
||||
public string[] Mappings { get; } = mappings;
|
||||
}
|
||||
}
|
||||
@@ -212,7 +212,7 @@ namespace SabreTools.Wrappers
|
||||
{
|
||||
// Determine the keys needed for this partition
|
||||
N3DSPartitionKeys? keys = GetDecryptionKeys(index, settings);
|
||||
if (keys == null)
|
||||
if (keys is null)
|
||||
{
|
||||
Console.WriteLine($"Partition {index} could not generate keys. Skipping...");
|
||||
return;
|
||||
@@ -637,7 +637,7 @@ namespace SabreTools.Wrappers
|
||||
{
|
||||
// Determine the keys needed for this partition
|
||||
N3DSPartitionKeys? keys = GetEncryptionKeys(index, settings);
|
||||
if (keys == null)
|
||||
if (keys is null)
|
||||
{
|
||||
Console.WriteLine($"Partition {index} could not generate keys. Skipping...");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user