2023-08-04 22:16:00 -04:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2023-08-09 21:00:02 -04:00
|
|
|
using SabreTools.Models.Internal;
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
namespace SabreTools.Serialization
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Serializer for Listxml models to internal structure
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class Internal
|
|
|
|
|
{
|
|
|
|
|
#region Serialize
|
|
|
|
|
|
2023-08-09 21:28:55 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Convert from <cref="Models.Listxml.M1"/> to <cref="MetadataFile"/>
|
|
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
public static MetadataFile ConvertToInternalModel(Models.Listxml.M1 item)
|
2023-08-09 21:28:55 -04:00
|
|
|
{
|
|
|
|
|
var metadataFile = new MetadataFile
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
[MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item),
|
2023-08-09 21:28:55 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (item?.Game != null && item.Game.Any())
|
2023-08-09 21:38:12 -04:00
|
|
|
metadataFile[MetadataFile.MachineKey] = item.Game.Select(ConvertMachineToInternalModel).ToArray();
|
2023-08-09 21:28:55 -04:00
|
|
|
|
|
|
|
|
return metadataFile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Convert from <cref="Models.Listxml.Mame"/> to <cref="MetadataFile"/>
|
|
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
public static MetadataFile ConvertToInternalModel(Models.Listxml.Mame item)
|
2023-08-09 21:28:55 -04:00
|
|
|
{
|
|
|
|
|
var metadataFile = new MetadataFile
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
[MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item),
|
2023-08-09 21:28:55 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (item?.Game != null && item.Game.Any())
|
2023-08-09 21:38:12 -04:00
|
|
|
metadataFile[MetadataFile.MachineKey] = item.Game.Select(ConvertMachineToInternalModel).ToArray();
|
2023-08-09 21:28:55 -04:00
|
|
|
|
|
|
|
|
return metadataFile;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-08 14:38:01 -04:00
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.M1"/> to <cref="Header"/>
|
2023-08-08 14:38:01 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Header ConvertHeaderToInternalModel(Models.Listxml.M1 item)
|
2023-08-08 14:38:01 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var header = new Header
|
2023-08-08 14:38:01 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Header.VersionKey] = item.Version,
|
2023-08-08 14:38:01 -04:00
|
|
|
};
|
|
|
|
|
return header;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Mame"/> to <cref="Header"/>
|
2023-08-08 14:38:01 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Header ConvertHeaderToInternalModel(Models.Listxml.Mame item)
|
2023-08-08 14:38:01 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var header = new Header
|
2023-08-08 14:38:01 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Header.BuildKey] = item.Build,
|
|
|
|
|
[Header.DebugKey] = item.Debug,
|
|
|
|
|
[Header.MameConfigKey] = item.MameConfig,
|
2023-08-08 14:38:01 -04:00
|
|
|
};
|
|
|
|
|
return header;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-05 01:11:11 -04:00
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.GameBase"/> to <cref="Machine"/>
|
2023-08-05 01:11:11 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Machine ConvertMachineToInternalModel(Models.Listxml.GameBase item)
|
2023-08-05 01:11:11 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var machine = new Machine
|
2023-08-05 01:11:11 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Machine.NameKey] = item.Name,
|
|
|
|
|
[Machine.SourceFileKey] = item.SourceFile,
|
|
|
|
|
[Machine.IsBiosKey] = item.IsBios,
|
|
|
|
|
[Machine.IsDeviceKey] = item.IsDevice,
|
|
|
|
|
[Machine.IsMechanicalKey] = item.IsMechanical,
|
|
|
|
|
[Machine.RunnableKey] = item.Runnable,
|
|
|
|
|
[Machine.CloneOfKey] = item.CloneOf,
|
|
|
|
|
[Machine.RomOfKey] = item.RomOf,
|
|
|
|
|
[Machine.SampleOfKey] = item.SampleOf,
|
|
|
|
|
[Machine.DescriptionKey] = item.Description,
|
|
|
|
|
[Machine.YearKey] = item.Year,
|
|
|
|
|
[Machine.ManufacturerKey] = item.Manufacturer,
|
|
|
|
|
[Machine.HistoryKey] = item.History,
|
2023-08-05 01:11:11 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (item.BiosSet != null && item.BiosSet.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var biosSets = new List<BiosSet>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var biosSet in item.BiosSet)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
biosSets.Add(ConvertToInternalModel(biosSet));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.BiosSetKey] = biosSets.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Rom != null && item.Rom.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var roms = new List<Rom>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var rom in item.Rom)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
roms.Add(ConvertToInternalModel(rom));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.RomKey] = roms.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Disk != null && item.Disk.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var disks = new List<Disk>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var disk in item.Disk)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
disks.Add(ConvertToInternalModel(disk));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.DiskKey] = disks.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.DeviceRef != null && item.DeviceRef.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var deviceRefs = new List<DeviceRef>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var deviceRef in item.DeviceRef)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
deviceRefs.Add(ConvertToInternalModel(deviceRef));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.DeviceRefKey] = deviceRefs.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Sample != null && item.Sample.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var samples = new List<Sample>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var sample in item.Sample)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
samples.Add(ConvertToInternalModel(sample));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.SampleKey] = samples.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Chip != null && item.Chip.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var chips = new List<Chip>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var chip in item.Chip)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
chips.Add(ConvertToInternalModel(chip));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.ChipKey] = chips.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Display != null && item.Display.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var displays = new List<Display>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var display in item.Display)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
displays.Add(ConvertToInternalModel(display));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.DisplayKey] = displays.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Video != null && item.Video.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var videos = new List<Video>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var video in item.Video)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
videos.Add(ConvertToInternalModel(video));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.VideoKey] = videos.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Sound != null)
|
2023-08-09 21:38:12 -04:00
|
|
|
machine[Machine.SoundKey] = ConvertToInternalModel(item.Sound);
|
2023-08-05 01:11:11 -04:00
|
|
|
|
|
|
|
|
if (item.Input != null)
|
2023-08-09 21:38:12 -04:00
|
|
|
machine[Machine.InputKey] = ConvertToInternalModel(item.Input);
|
2023-08-05 01:11:11 -04:00
|
|
|
|
|
|
|
|
if (item.DipSwitch != null && item.DipSwitch.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var dipSwitches = new List<DipSwitch>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var dipSwitch in item.DipSwitch)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
dipSwitches.Add(ConvertToInternalModel(dipSwitch));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.DipSwitchKey] = dipSwitches.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Configuration != null && item.Configuration.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var configurations = new List<Configuration>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var configuration in item.Configuration)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
configurations.Add(ConvertToInternalModel(configuration));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.ConfigurationKey] = configurations.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Port != null && item.Port.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var ports = new List<Port>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var port in item.Port)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
ports.Add(ConvertToInternalModel(port));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.PortKey] = ports.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Adjuster != null && item.Adjuster.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var adjusters = new List<Adjuster>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var adjuster in item.Adjuster)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
adjusters.Add(ConvertToInternalModel(adjuster));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.AdjusterKey] = adjusters.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Driver != null)
|
2023-08-09 21:38:12 -04:00
|
|
|
machine[Machine.DriverKey] = ConvertToInternalModel(item.Driver);
|
2023-08-05 01:11:11 -04:00
|
|
|
|
|
|
|
|
if (item.Feature != null && item.Feature.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var features = new List<Feature>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var feature in item.Feature)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
features.Add(ConvertToInternalModel(feature));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.FeatureKey] = features.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Device != null && item.Device.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var devices = new List<Device>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var device in item.Device)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
devices.Add(ConvertToInternalModel(device));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.DeviceKey] = devices.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.Slot != null && item.Slot.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var slots = new List<Slot>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var slot in item.Slot)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
slots.Add(ConvertToInternalModel(slot));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.SlotKey] = slots.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.SoftwareList != null && item.SoftwareList.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var softwareLists = new List<SoftwareList>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var softwareList in item.SoftwareList)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
softwareLists.Add(ConvertToInternalModel(softwareList));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.SoftwareListKey] = softwareLists.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.RamOption != null && item.RamOption.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var ramOptions = new List<RamOption>();
|
2023-08-05 01:11:11 -04:00
|
|
|
foreach (var ramOption in item.RamOption)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
ramOptions.Add(ConvertToInternalModel(ramOption));
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
machine[Machine.RamOptionKey] = ramOptions.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return machine;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Adjuster"/> to <cref="Adjuster"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Adjuster ConvertToInternalModel(Models.Listxml.Adjuster item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var adjuster = new Adjuster
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Adjuster.NameKey] = item.Name,
|
|
|
|
|
[Adjuster.DefaultKey] = item.Default,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (item.Condition != null)
|
2023-08-09 21:38:12 -04:00
|
|
|
adjuster[Adjuster.ConditionKey] = ConvertToInternalModel(item.Condition);
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
return adjuster;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Analog"/> to <cref="Analog"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Analog ConvertToInternalModel(Models.Listxml.Analog item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var analog = new Analog
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Analog.MaskKey] = item.Mask,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return analog;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.BiosSet"/> to <cref="BiosSet"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static BiosSet ConvertToInternalModel(Models.Listxml.BiosSet item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var biosset = new BiosSet
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[BiosSet.NameKey] = item.Name,
|
|
|
|
|
[BiosSet.DescriptionKey] = item.Description,
|
|
|
|
|
[BiosSet.DefaultKey] = item.Default,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return biosset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Chip"/> to <cref="Chip"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Chip ConvertToInternalModel(Models.Listxml.Chip item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var chip = new Chip
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Chip.NameKey] = item.Name,
|
|
|
|
|
[Chip.TagKey] = item.Tag,
|
|
|
|
|
[Chip.TypeKey] = item.Type,
|
|
|
|
|
[Chip.SoundOnlyKey] = item.SoundOnly,
|
|
|
|
|
[Chip.ClockKey] = item.Clock,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return chip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Condition"/> to <cref="Condition"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Condition ConvertToInternalModel(Models.Listxml.Condition item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var condition = new Condition
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Condition.TagKey] = item.Tag,
|
|
|
|
|
[Condition.MaskKey] = item.Mask,
|
|
|
|
|
[Condition.RelationKey] = item.Relation,
|
|
|
|
|
[Condition.ValueKey] = item.Value,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return condition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Configuration"/> to <cref="Configuration"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Configuration ConvertToInternalModel(Models.Listxml.Configuration item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var configuration = new Configuration
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Configuration.NameKey] = item.Name,
|
|
|
|
|
[Configuration.TagKey] = item.Tag,
|
|
|
|
|
[Configuration.MaskKey] = item.Mask,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (item.Condition != null)
|
2023-08-09 21:38:12 -04:00
|
|
|
configuration[Configuration.ConditionKey] = ConvertToInternalModel(item.Condition);
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
if (item.ConfLocation != null && item.ConfLocation.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var confLocations = new List<ConfLocation>();
|
2023-08-04 22:16:00 -04:00
|
|
|
foreach (var confLocation in item.ConfLocation)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
confLocations.Add(ConvertToInternalModel(confLocation));
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
configuration[Configuration.ConfLocationKey] = confLocations.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.ConfSetting != null && item.ConfSetting.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var confSettings = new List<ConfSetting>();
|
2023-08-04 22:16:00 -04:00
|
|
|
foreach (var confSetting in item.ConfSetting)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
confSettings.Add(ConvertToInternalModel(confSetting));
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
configuration[Configuration.ConfSettingKey] = confSettings.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return configuration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.ConfLocation"/> to <cref="ConfLocation"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static ConfLocation ConvertToInternalModel(Models.Listxml.ConfLocation item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var confLocation = new ConfLocation
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[ConfLocation.NameKey] = item.Name,
|
|
|
|
|
[ConfLocation.NumberKey] = item.Number,
|
|
|
|
|
[ConfLocation.InvertedKey] = item.Inverted,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return confLocation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.ConfSetting"/> to <cref="ConfSetting"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static ConfSetting ConvertToInternalModel(Models.Listxml.ConfSetting item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var confSetting = new ConfSetting
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[ConfSetting.NameKey] = item.Name,
|
|
|
|
|
[ConfSetting.ValueKey] = item.Value,
|
|
|
|
|
[ConfSetting.DefaultKey] = item.Default,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (item.Condition != null)
|
2023-08-09 21:38:12 -04:00
|
|
|
confSetting[ConfSetting.ConditionKey] = ConvertToInternalModel(item.Condition);
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
return confSetting;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Control"/> to <cref="Control"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Control ConvertToInternalModel(Models.Listxml.Control item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var control = new Control
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Control.TypeKey] = item.Type,
|
|
|
|
|
[Control.PlayerKey] = item.Player,
|
|
|
|
|
[Control.ButtonsKey] = item.Buttons,
|
|
|
|
|
[Control.ReqButtonsKey] = item.ReqButtons,
|
|
|
|
|
[Control.MinimumKey] = item.Minimum,
|
|
|
|
|
[Control.MaximumKey] = item.Maximum,
|
|
|
|
|
[Control.SensitivityKey] = item.Sensitivity,
|
|
|
|
|
[Control.KeyDeltaKey] = item.KeyDelta,
|
|
|
|
|
[Control.ReverseKey] = item.Reverse,
|
|
|
|
|
[Control.WaysKey] = item.Ways,
|
|
|
|
|
[Control.Ways2Key] = item.Ways2,
|
|
|
|
|
[Control.Ways3Key] = item.Ways3,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return control;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Device"/> to <cref="Device"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Device ConvertToInternalModel(Models.Listxml.Device item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var device = new Device
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Device.TypeKey] = item.Type,
|
|
|
|
|
[Device.TagKey] = item.Tag,
|
|
|
|
|
[Device.FixedImageKey] = item.FixedImage,
|
|
|
|
|
[Device.MandatoryKey] = item.Mandatory,
|
|
|
|
|
[Device.InterfaceKey] = item.Interface,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (item.Instance != null)
|
2023-08-09 21:38:12 -04:00
|
|
|
device[Device.InstanceKey] = ConvertToInternalModel(item.Instance);
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
if (item.Extension != null && item.Extension.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var extensions = new List<Extension>();
|
2023-08-04 22:16:00 -04:00
|
|
|
foreach (var extension in item.Extension)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
extensions.Add(ConvertToInternalModel(extension));
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
device[Device.ExtensionKey] = extensions.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return device;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.DeviceRef"/> to <cref="DeviceRef"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static DeviceRef ConvertToInternalModel(Models.Listxml.DeviceRef item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var deviceRef = new DeviceRef
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[DeviceRef.NameKey] = item.Name,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return deviceRef;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.DipLocation"/> to <cref="DipLocation"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static DipLocation ConvertToInternalModel(Models.Listxml.DipLocation item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var dipLocation = new DipLocation
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[DipLocation.NameKey] = item.Name,
|
|
|
|
|
[DipLocation.NumberKey] = item.Number,
|
|
|
|
|
[DipLocation.InvertedKey] = item.Inverted,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return dipLocation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.DipSwitch"/> to <cref="DipSwitch"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static DipSwitch ConvertToInternalModel(Models.Listxml.DipSwitch item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var dipSwitch = new DipSwitch
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[DipSwitch.NameKey] = item.Name,
|
|
|
|
|
[DipSwitch.TagKey] = item.Tag,
|
|
|
|
|
[DipSwitch.MaskKey] = item.Mask,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (item.Condition != null)
|
2023-08-09 21:38:12 -04:00
|
|
|
dipSwitch[DipSwitch.ConditionKey] = ConvertToInternalModel(item.Condition);
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
if (item.DipLocation != null && item.DipLocation.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var dipLocations = new List<DipLocation>();
|
2023-08-04 22:16:00 -04:00
|
|
|
foreach (var dipLocation in item.DipLocation)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
dipLocations.Add(ConvertToInternalModel(dipLocation));
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
dipSwitch[DipSwitch.DipLocationKey] = dipLocations.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.DipValue != null && item.DipValue.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var dipValues = new List<DipValue>();
|
2023-08-04 22:16:00 -04:00
|
|
|
foreach (var dipValue in item.DipValue)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
dipValues.Add(ConvertToInternalModel(dipValue));
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
dipSwitch[DipSwitch.DipValueKey] = dipValues.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dipSwitch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.DipValue"/> to <cref="DipValue"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static DipValue ConvertToInternalModel(Models.Listxml.DipValue item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var dipValue = new DipValue
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[DipValue.NameKey] = item.Name,
|
|
|
|
|
[DipValue.ValueKey] = item.Value,
|
|
|
|
|
[DipValue.DefaultKey] = item.Default,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (item.Condition != null)
|
2023-08-09 21:38:12 -04:00
|
|
|
dipValue[DipValue.ConditionKey] = ConvertToInternalModel(item.Condition);
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
return dipValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Disk"/> to <cref="Disk"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Disk ConvertToInternalModel(Models.Listxml.Disk item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var disk = new Disk
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Disk.NameKey] = item.Name,
|
|
|
|
|
[Disk.MD5Key] = item.MD5,
|
|
|
|
|
[Disk.SHA1Key] = item.SHA1,
|
|
|
|
|
[Disk.MergeKey] = item.Merge,
|
|
|
|
|
[Disk.RegionKey] = item.Region,
|
|
|
|
|
[Disk.IndexKey] = item.Index,
|
|
|
|
|
[Disk.WritableKey] = item.Writable,
|
|
|
|
|
[Disk.StatusKey] = item.Status,
|
|
|
|
|
[Disk.OptionalKey] = item.Optional,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return disk;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Display"/> to <cref="Display"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Display ConvertToInternalModel(Models.Listxml.Display item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var display = new Display
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Display.TagKey] = item.Tag,
|
|
|
|
|
[Display.TypeKey] = item.Type,
|
|
|
|
|
[Display.RotateKey] = item.Rotate,
|
|
|
|
|
[Display.FlipXKey] = item.FlipX,
|
|
|
|
|
[Display.WidthKey] = item.Width,
|
|
|
|
|
[Display.HeightKey] = item.Height,
|
|
|
|
|
[Display.RefreshKey] = item.Refresh,
|
|
|
|
|
[Display.PixClockKey] = item.PixClock,
|
|
|
|
|
[Display.HTotalKey] = item.HTotal,
|
|
|
|
|
[Display.HBEndKey] = item.HBEnd,
|
|
|
|
|
[Display.HBStartKey] = item.HBStart,
|
|
|
|
|
[Display.VTotalKey] = item.VTotal,
|
|
|
|
|
[Display.VBEndKey] = item.VBEnd,
|
|
|
|
|
[Display.VBStartKey] = item.VBStart,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return display;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Driver"/> to <cref="Driver"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Driver ConvertToInternalModel(Models.Listxml.Driver item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var driver = new Driver
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Driver.StatusKey] = item.Status,
|
|
|
|
|
[Driver.ColorKey] = item.Color,
|
|
|
|
|
[Driver.SoundKey] = item.Sound,
|
|
|
|
|
[Driver.PaletteSizeKey] = item.PaletteSize,
|
|
|
|
|
[Driver.EmulationKey] = item.Emulation,
|
|
|
|
|
[Driver.CocktailKey] = item.Cocktail,
|
|
|
|
|
[Driver.SaveStateKey] = item.SaveState,
|
|
|
|
|
[Driver.RequiresArtworkKey] = item.RequiresArtwork,
|
|
|
|
|
[Driver.UnofficialKey] = item.Unofficial,
|
|
|
|
|
[Driver.NoSoundHardwareKey] = item.NoSoundHardware,
|
|
|
|
|
[Driver.IncompleteKey] = item.Incomplete,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return driver;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Extension"/> to <cref="Extension"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Extension ConvertToInternalModel(Models.Listxml.Extension item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var extension = new Extension
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Extension.NameKey] = item.Name,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return extension;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Feature"/> to <cref="Feature"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Feature ConvertToInternalModel(Models.Listxml.Feature item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var feature = new Feature
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Feature.TypeKey] = item.Type,
|
|
|
|
|
[Feature.StatusKey] = item.Status,
|
|
|
|
|
[Feature.OverallKey] = item.Overall,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return feature;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Input"/> to <cref="Input"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Input ConvertToInternalModel(Models.Listxml.Input item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var input = new Input
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Input.ServiceKey] = item.Service,
|
|
|
|
|
[Input.TiltKey] = item.Tilt,
|
|
|
|
|
[Input.PlayersKey] = item.Players,
|
|
|
|
|
[Input.ControlKey] = item.ControlAttr,
|
|
|
|
|
[Input.ButtonsKey] = item.Buttons,
|
|
|
|
|
[Input.CoinsKey] = item.Coins,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (item.Control != null && item.Control.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var controls = new List<Control>();
|
2023-08-04 22:16:00 -04:00
|
|
|
foreach (var control in item.Control)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
controls.Add(ConvertToInternalModel(control));
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
input[Input.ControlKey] = controls.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return input;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Instance"/> to <cref="Instance"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Instance ConvertToInternalModel(Models.Listxml.Instance item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var instance = new Instance
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Instance.NameKey] = item.Name,
|
|
|
|
|
[Instance.BriefNameKey] = item.BriefName,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Port"/> to <cref="Port"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Port ConvertToInternalModel(Models.Listxml.Port item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var port = new Port
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Port.TagKey] = item.Tag,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (item.Analog != null && item.Analog.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var analogs = new List<Analog>();
|
2023-08-04 22:16:00 -04:00
|
|
|
foreach (var analog in item.Analog)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
analogs.Add(ConvertToInternalModel(analog));
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
port[Port.AnalogKey] = analogs.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return port;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.RamOption"/> to <cref="RamOption"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static RamOption ConvertToInternalModel(Models.Listxml.RamOption item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var ramOption = new RamOption
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[RamOption.NameKey] = item.Name,
|
|
|
|
|
[RamOption.DefaultKey] = item.Default,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return ramOption;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Rom"/> to <cref="Rom"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Rom ConvertToInternalModel(Models.Listxml.Rom item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var rom = new Rom
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Rom.NameKey] = item.Name,
|
|
|
|
|
[Rom.BiosKey] = item.Bios,
|
|
|
|
|
[Rom.SizeKey] = item.Size,
|
|
|
|
|
[Rom.CRCKey] = item.CRC,
|
|
|
|
|
[Rom.SHA1Key] = item.SHA1,
|
|
|
|
|
[Rom.MergeKey] = item.Merge,
|
|
|
|
|
[Rom.RegionKey] = item.Region,
|
|
|
|
|
[Rom.OffsetKey] = item.Offset,
|
|
|
|
|
[Rom.StatusKey] = item.Status,
|
|
|
|
|
[Rom.OptionalKey] = item.Optional,
|
|
|
|
|
[Rom.DisposeKey] = item.Dispose,
|
|
|
|
|
[Rom.SoundOnlyKey] = item.SoundOnly,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return rom;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Sample"/> to <cref="Sample"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Sample ConvertToInternalModel(Models.Listxml.Sample item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var sample = new Sample
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Sample.NameKey] = item.Name,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return sample;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Slot"/> to <cref="Slot"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Slot ConvertToInternalModel(Models.Listxml.Slot item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var slot = new Slot
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Slot.NameKey] = item.Name,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (item.SlotOption != null && item.SlotOption.Any())
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var slotOptions = new List<SlotOption>();
|
2023-08-04 22:16:00 -04:00
|
|
|
foreach (var slotOption in item.SlotOption)
|
|
|
|
|
{
|
2023-08-09 21:38:12 -04:00
|
|
|
slotOptions.Add(ConvertToInternalModel(slotOption));
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
2023-08-09 21:00:02 -04:00
|
|
|
slot[Slot.SlotOptionKey] = slotOptions.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return slot;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.SlotOption"/> to <cref="SlotOption"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static SlotOption ConvertToInternalModel(Models.Listxml.SlotOption item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var slotOption = new SlotOption
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[SlotOption.NameKey] = item.Name,
|
|
|
|
|
[SlotOption.DevNameKey] = item.DevName,
|
|
|
|
|
[SlotOption.DefaultKey] = item.Default,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return slotOption;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.SoftwareList"/> to <cref="SoftwareList"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static SoftwareList ConvertToInternalModel(Models.Listxml.SoftwareList item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var softwareList = new SoftwareList
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[SoftwareList.TagKey] = item.Tag,
|
|
|
|
|
[SoftwareList.NameKey] = item.Name,
|
|
|
|
|
[SoftwareList.StatusKey] = item.Status,
|
|
|
|
|
[SoftwareList.FilterKey] = item.Filter,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return softwareList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Sound"/> to <cref="Sound"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Sound ConvertToInternalModel(Models.Listxml.Sound item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var sound = new Sound
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Sound.ChannelsKey] = item.Channels,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return sound;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Models.Listxml.Video"/> to <cref="Video"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:38:12 -04:00
|
|
|
private static Video ConvertToInternalModel(Models.Listxml.Video item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
var video = new Video
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
[Video.ScreenKey] = item.Screen,
|
|
|
|
|
[Video.OrientationKey] = item.Orientation,
|
|
|
|
|
[Video.WidthKey] = item.Width,
|
|
|
|
|
[Video.HeightKey] = item.Height,
|
|
|
|
|
[Video.AspectXKey] = item.AspectX,
|
|
|
|
|
[Video.AspectYKey] = item.AspectY,
|
|
|
|
|
[Video.RefreshKey] = item.Refresh,
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return video;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Deserialize
|
|
|
|
|
|
2023-08-09 20:52:10 -04:00
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Header"/> to <cref="Models.Listxml.M1"/>
|
2023-08-09 20:52:10 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
public static Models.Listxml.M1? ConvertHeaderToListxmlM1(Header? item)
|
2023-08-09 20:52:10 -04:00
|
|
|
{
|
|
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
var m1 = new Models.Listxml.M1
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Version = item.ReadString(Header.VersionKey),
|
2023-08-09 20:52:10 -04:00
|
|
|
};
|
|
|
|
|
return m1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Header"/> to <cref="Models.Listxml.Mame"/>
|
2023-08-09 20:52:10 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
public static Models.Listxml.Mame? ConvertHeaderToListxmlMame(Header? item)
|
2023-08-09 20:52:10 -04:00
|
|
|
{
|
|
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
var mame = new Models.Listxml.Mame
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Build = item.ReadString(Header.BuildKey),
|
|
|
|
|
Debug = item.ReadString(Header.DebugKey),
|
|
|
|
|
MameConfig = item.ReadString(Header.MameConfigKey),
|
2023-08-09 20:52:10 -04:00
|
|
|
};
|
|
|
|
|
return mame;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-05 01:11:11 -04:00
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Machine"/> to <cref="Models.Listxml.GameBase"/>
|
2023-08-05 01:11:11 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
public static Models.Listxml.GameBase? ConvertMachineToListxml(Machine? item)
|
2023-08-05 01:11:11 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-05 01:11:11 -04:00
|
|
|
var machine = new Models.Listxml.Machine
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(Machine.NameKey),
|
|
|
|
|
SourceFile = item.ReadString(Machine.SourceFileKey),
|
|
|
|
|
IsBios = item.ReadString(Machine.IsBiosKey),
|
|
|
|
|
IsDevice = item.ReadString(Machine.IsDeviceKey),
|
|
|
|
|
IsMechanical = item.ReadString(Machine.IsMechanicalKey),
|
|
|
|
|
Runnable = item.ReadString(Machine.RunnableKey),
|
|
|
|
|
CloneOf = item.ReadString(Machine.CloneOfKey),
|
|
|
|
|
RomOf = item.ReadString(Machine.RomOfKey),
|
|
|
|
|
SampleOf = item.ReadString(Machine.SampleOfKey),
|
|
|
|
|
Description = item.ReadString(Machine.DescriptionKey),
|
|
|
|
|
Year = item.ReadString(Machine.YearKey),
|
|
|
|
|
Manufacturer = item.ReadString(Machine.ManufacturerKey),
|
|
|
|
|
History = item.ReadString(Machine.HistoryKey),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var biosSets = item.Read<BiosSet[]>(Machine.BiosSetKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.BiosSet = biosSets?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var roms = item.Read<Rom[]>(Machine.RomKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Rom = roms?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var disks = item.Read<Disk[]>(Machine.DiskKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Disk = disks?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var deviceRefs = item.Read<DeviceRef[]>(Machine.DeviceRefKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.DeviceRef = deviceRefs?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var samples = item.Read<Sample[]>(Machine.SampleKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Sample = samples?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var chips = item.Read<Chip[]>(Machine.ChipKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Chip = chips?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var displays = item.Read<Display[]>(Machine.DisplayKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Display = displays?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var videos = item.Read<Video[]>(Machine.VideoKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Video = videos?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var sound = item.Read<Sound>(Machine.SoundKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Sound = ConvertToListxml(sound);
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var input = item.Read<Input>(Machine.InputKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Input = ConvertToListxml(input);
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var dipSwitches = item.Read<DipSwitch[]>(Machine.DipSwitchKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.DipSwitch = dipSwitches?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var configurations = item.Read<Configuration[]>(Machine.ConfigurationKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Configuration = configurations?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var ports = item.Read<Port[]>(Machine.PortKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Port = ports?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var adjusters = item.Read<Adjuster[]>(Machine.AdjusterKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Adjuster = adjusters?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var driver = item.Read<Driver>(Machine.DriverKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Driver = ConvertToListxml(driver);
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var features = item.Read<Feature[]>(Machine.FeatureKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Feature = features?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var devices = item.Read<Device[]>(Machine.DeviceKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Device = devices?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var slots = item.Read<Slot[]>(Machine.SlotKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.Slot = slots?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var softwareLists = item.Read<SoftwareList[]>(Machine.SoftwareListKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.SoftwareList = softwareLists?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var ramOptions = item.Read<RamOption[]>(Machine.RamOptionKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
machine.RamOption = ramOptions?.Select(ConvertToListxml)?.ToArray();
|
2023-08-05 01:11:11 -04:00
|
|
|
|
|
|
|
|
return machine;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Adjuster"/> to <cref="Models.Listxml.Adjuster"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Adjuster? ConvertToListxml(Adjuster? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var adjuster = new Models.Listxml.Adjuster
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(Adjuster.NameKey),
|
|
|
|
|
Default = item.ReadString(Adjuster.DefaultKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var condition = item.Read<Condition>(Adjuster.ConditionKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
adjuster.Condition = ConvertToListxml(condition);
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
return adjuster;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Analog"/> to <cref="Models.Listxml.Analog"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Analog? ConvertToListxml(Analog? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var analog = new Models.Listxml.Analog
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Mask = item.ReadString(Analog.MaskKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return analog;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="BiosSet"/> to <cref="Models.Listxml.BiosSet"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.BiosSet? ConvertToListxml(BiosSet? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var biosset = new Models.Listxml.BiosSet
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(BiosSet.NameKey),
|
|
|
|
|
Description = item.ReadString(BiosSet.DescriptionKey),
|
|
|
|
|
Default = item.ReadString(BiosSet.DefaultKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return biosset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Chip"/> to <cref="Models.Listxml.Chip"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Chip? ConvertToListxml(Chip? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var chip = new Models.Listxml.Chip
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(Chip.NameKey),
|
|
|
|
|
Tag = item.ReadString(Chip.TagKey),
|
|
|
|
|
Type = item.ReadString(Chip.TypeKey),
|
|
|
|
|
SoundOnly = item.ReadString(Chip.SoundOnlyKey),
|
|
|
|
|
Clock = item.ReadString(Chip.ClockKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return chip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Condition"/> to <cref="Models.Listxml.Condition"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Condition? ConvertToListxml(Condition? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var condition = new Models.Listxml.Condition
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Tag = item.ReadString(Condition.TagKey),
|
|
|
|
|
Mask = item.ReadString(Condition.MaskKey),
|
|
|
|
|
Relation = item.ReadString(Condition.RelationKey),
|
|
|
|
|
Value = item.ReadString(Condition.ValueKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return condition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Configuration"/> to <cref="Models.Listxml.Configuration"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Configuration? ConvertToListxml(Configuration? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var configuration = new Models.Listxml.Configuration
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(Configuration.NameKey),
|
|
|
|
|
Tag = item.ReadString(Configuration.TagKey),
|
|
|
|
|
Mask = item.ReadString(Configuration.MaskKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var condition = item.Read<Condition>(Configuration.ConditionKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
configuration.Condition = ConvertToListxml(condition);
|
2023-08-04 22:16:00 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var confLocations = item.Read<ConfLocation[]>(Configuration.ConfLocationKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
configuration.ConfLocation = confLocations?.Select(ConvertToListxml)?.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var confSettings = item.Read<ConfSetting[]>(Configuration.ConfSettingKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
configuration.ConfSetting = confSettings?.Select(ConvertToListxml)?.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
return configuration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="ConfLocation"/> to <cref="Models.Listxml.ConfLocation"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.ConfLocation? ConvertToListxml(ConfLocation? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var confLocation = new Models.Listxml.ConfLocation
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(ConfLocation.NameKey),
|
|
|
|
|
Number = item.ReadString(ConfLocation.NumberKey),
|
|
|
|
|
Inverted = item.ReadString(ConfLocation.InvertedKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return confLocation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="ConfSetting"/> to <cref="Models.Listxml.ConfSetting"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.ConfSetting? ConvertToListxml(ConfSetting? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var confSetting = new Models.Listxml.ConfSetting
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(ConfSetting.NameKey),
|
|
|
|
|
Value = item.ReadString(ConfSetting.ValueKey),
|
|
|
|
|
Default = item.ReadString(ConfSetting.DefaultKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var condition = item.Read<Condition>(ConfSetting.ConditionKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
confSetting.Condition = ConvertToListxml(condition);
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
return confSetting;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Control"/> to <cref="Models.Listxml.Control"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Control? ConvertToListxml(Control? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var control = new Models.Listxml.Control
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Type = item.ReadString(Control.TypeKey),
|
|
|
|
|
Player = item.ReadString(Control.PlayerKey),
|
|
|
|
|
Buttons = item.ReadString(Control.ButtonsKey),
|
|
|
|
|
ReqButtons = item.ReadString(Control.ReqButtonsKey),
|
|
|
|
|
Minimum = item.ReadString(Control.MinimumKey),
|
|
|
|
|
Maximum = item.ReadString(Control.MaximumKey),
|
|
|
|
|
Sensitivity = item.ReadString(Control.SensitivityKey),
|
|
|
|
|
KeyDelta = item.ReadString(Control.KeyDeltaKey),
|
|
|
|
|
Reverse = item.ReadString(Control.ReverseKey),
|
|
|
|
|
Ways = item.ReadString(Control.WaysKey),
|
|
|
|
|
Ways2 = item.ReadString(Control.Ways2Key),
|
|
|
|
|
Ways3 = item.ReadString(Control.Ways3Key),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return control;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Device"/> to <cref="Models.Listxml.Device"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Device? ConvertToListxml(Device? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var device = new Models.Listxml.Device
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Type = item.ReadString(Device.TypeKey),
|
|
|
|
|
Tag = item.ReadString(Device.TagKey),
|
|
|
|
|
FixedImage = item.ReadString(Device.FixedImageKey),
|
|
|
|
|
Mandatory = item.ReadString(Device.MandatoryKey),
|
|
|
|
|
Interface = item.ReadString(Device.InterfaceKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var instance = item.Read<Instance>(Device.InstanceKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
device.Instance = ConvertToListxml(instance);
|
2023-08-04 22:16:00 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var extensions = item.Read<Extension[]>(Device.ExtensionKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
device.Extension = extensions?.Select(ConvertToListxml)?.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
return device;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="DeviceRef"/> to <cref="Models.Listxml.DeviceRef"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.DeviceRef? ConvertToListxml(DeviceRef? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var deviceRef = new Models.Listxml.DeviceRef
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(DeviceRef.NameKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return deviceRef;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="DipLocation"/> to <cref="Models.Listxml.DipLocation"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.DipLocation? ConvertToListxml(DipLocation? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var dipLocation = new Models.Listxml.DipLocation
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(DipLocation.NameKey),
|
|
|
|
|
Number = item.ReadString(DipLocation.NumberKey),
|
|
|
|
|
Inverted = item.ReadString(DipLocation.InvertedKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return dipLocation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="DipSwitch"/> to <cref="Models.Listxml.DipSwitch"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.DipSwitch? ConvertToListxml(DipSwitch? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var dipSwitch = new Models.Listxml.DipSwitch
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(DipSwitch.NameKey),
|
|
|
|
|
Tag = item.ReadString(DipSwitch.TagKey),
|
|
|
|
|
Mask = item.ReadString(DipSwitch.MaskKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var condition = item.Read<Condition>(DipSwitch.ConditionKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
dipSwitch.Condition = ConvertToListxml(condition);
|
2023-08-04 22:16:00 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var dipLocations = item.Read<DipLocation[]>(DipSwitch.DipLocationKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
dipSwitch.DipLocation = dipLocations?.Select(ConvertToListxml)?.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var dipValues = item.Read<DipValue[]>(DipSwitch.DipValueKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
dipSwitch.DipValue = dipValues?.Select(ConvertToListxml)?.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
return dipSwitch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="DipValue"/> to <cref="Models.Listxml.DipValue"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.DipValue? ConvertToListxml(DipValue? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var dipValue = new Models.Listxml.DipValue
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(DipValue.NameKey),
|
|
|
|
|
Value = item.ReadString(DipValue.ValueKey),
|
|
|
|
|
Default = item.ReadString(DipValue.DefaultKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var condition = item.Read<Condition>(DipValue.ConditionKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
dipValue.Condition = ConvertToListxml(condition);
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
return dipValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Disk"/> to <cref="Models.Listxml.Disk"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Disk? ConvertToListxml(Disk? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var disk = new Models.Listxml.Disk
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(Disk.NameKey),
|
|
|
|
|
MD5 = item.ReadString(Disk.MD5Key),
|
|
|
|
|
SHA1 = item.ReadString(Disk.SHA1Key),
|
|
|
|
|
Merge = item.ReadString(Disk.MergeKey),
|
|
|
|
|
Region = item.ReadString(Disk.RegionKey),
|
|
|
|
|
Index = item.ReadString(Disk.IndexKey),
|
|
|
|
|
Writable = item.ReadString(Disk.WritableKey),
|
|
|
|
|
Status = item.ReadString(Disk.StatusKey),
|
|
|
|
|
Optional = item.ReadString(Disk.OptionalKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return disk;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Display"/> to <cref="Models.Listxml.Display"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Display? ConvertToListxml(Display? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var display = new Models.Listxml.Display
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Tag = item.ReadString(Display.TagKey),
|
|
|
|
|
Type = item.ReadString(Display.TypeKey),
|
|
|
|
|
Rotate = item.ReadString(Display.RotateKey),
|
|
|
|
|
FlipX = item.ReadString(Display.FlipXKey),
|
|
|
|
|
Width = item.ReadString(Display.WidthKey),
|
|
|
|
|
Height = item.ReadString(Display.HeightKey),
|
|
|
|
|
Refresh = item.ReadString(Display.RefreshKey),
|
|
|
|
|
PixClock = item.ReadString(Display.PixClockKey),
|
|
|
|
|
HTotal = item.ReadString(Display.HTotalKey),
|
|
|
|
|
HBEnd = item.ReadString(Display.HBEndKey),
|
|
|
|
|
HBStart = item.ReadString(Display.HBStartKey),
|
|
|
|
|
VTotal = item.ReadString(Display.VTotalKey),
|
|
|
|
|
VBEnd = item.ReadString(Display.VBEndKey),
|
|
|
|
|
VBStart = item.ReadString(Display.VBStartKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return display;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Driver"/> to <cref="Models.Listxml.Driver"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Driver? ConvertToListxml(Driver? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var driver = new Models.Listxml.Driver
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Status = item.ReadString(Driver.StatusKey),
|
|
|
|
|
Color = item.ReadString(Driver.ColorKey),
|
|
|
|
|
Sound = item.ReadString(Driver.SoundKey),
|
|
|
|
|
PaletteSize = item.ReadString(Driver.PaletteSizeKey),
|
|
|
|
|
Emulation = item.ReadString(Driver.EmulationKey),
|
|
|
|
|
Cocktail = item.ReadString(Driver.CocktailKey),
|
|
|
|
|
SaveState = item.ReadString(Driver.SaveStateKey),
|
|
|
|
|
RequiresArtwork = item.ReadString(Driver.RequiresArtworkKey),
|
|
|
|
|
Unofficial = item.ReadString(Driver.UnofficialKey),
|
|
|
|
|
NoSoundHardware = item.ReadString(Driver.NoSoundHardwareKey),
|
|
|
|
|
Incomplete = item.ReadString(Driver.IncompleteKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return driver;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Extension"/> to <cref="Models.Listxml.Extension"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Extension? ConvertToListxml(Extension? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var extension = new Models.Listxml.Extension
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(Extension.NameKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return extension;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Feature"/> to <cref="Models.Listxml.Feature"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Feature? ConvertToListxml(Feature? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var feature = new Models.Listxml.Feature
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Type = item.ReadString(Feature.TypeKey),
|
|
|
|
|
Status = item.ReadString(Feature.StatusKey),
|
|
|
|
|
Overall = item.ReadString(Feature.OverallKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return feature;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Input"/> to <cref="Models.Listxml.Input"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Input? ConvertToListxml(Input? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var input = new Models.Listxml.Input
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Service = item.ReadString(Input.ServiceKey),
|
|
|
|
|
Tilt = item.ReadString(Input.TiltKey),
|
|
|
|
|
Players = item.ReadString(Input.PlayersKey),
|
|
|
|
|
ControlAttr = item.ReadString(Input.ControlKey),
|
|
|
|
|
Buttons = item.ReadString(Input.ButtonsKey),
|
|
|
|
|
Coins = item.ReadString(Input.CoinsKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var controls = item.Read<Control[]>(Input.ControlKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
input.Control = controls?.Select(ConvertToListxml)?.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
return input;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Instance"/> to <cref="Models.Listxml.Instance"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Instance? ConvertToListxml(Instance? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var instance = new Models.Listxml.Instance
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(Instance.NameKey),
|
|
|
|
|
BriefName = item.ReadString(Instance.BriefNameKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Port"/> to <cref="Models.Listxml.Port"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Port? ConvertToListxml(Port? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
var port = new Models.Listxml.Port
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Tag = item.ReadString(Port.TagKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var analogs = item.Read<Analog[]>(Port.AnalogKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
port.Analog = analogs?.Select(ConvertToListxml)?.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
|
2023-08-08 12:04:07 -04:00
|
|
|
return port;
|
2023-08-04 22:16:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="RamOption"/> to <cref="Models.Listxml.RamOption"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.RamOption? ConvertToListxml(RamOption? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var ramOption = new Models.Listxml.RamOption
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(RamOption.NameKey),
|
|
|
|
|
Default = item.ReadString(RamOption.DefaultKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return ramOption;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Rom"/> to <cref="Models.Listxml.Rom"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Rom? ConvertToListxml(Rom? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var rom = new Models.Listxml.Rom
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(Rom.NameKey),
|
|
|
|
|
Bios = item.ReadString(Rom.BiosKey),
|
|
|
|
|
Size = item.ReadString(Rom.SizeKey),
|
|
|
|
|
CRC = item.ReadString(Rom.CRCKey),
|
|
|
|
|
SHA1 = item.ReadString(Rom.SHA1Key),
|
|
|
|
|
Merge = item.ReadString(Rom.MergeKey),
|
|
|
|
|
Region = item.ReadString(Rom.RegionKey),
|
|
|
|
|
Offset = item.ReadString(Rom.OffsetKey),
|
|
|
|
|
Status = item.ReadString(Rom.StatusKey),
|
|
|
|
|
Optional = item.ReadString(Rom.OptionalKey),
|
|
|
|
|
Dispose = item.ReadString(Rom.DisposeKey),
|
|
|
|
|
SoundOnly = item.ReadString(Rom.SoundOnlyKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return rom;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Sample"/> to <cref="Models.Listxml.Sample"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Sample? ConvertToListxml(Sample? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var sample = new Models.Listxml.Sample
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(Sample.NameKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return sample;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Slot"/> to <cref="Models.Listxml.Slot"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Slot? ConvertToListxml(Slot? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var slot = new Models.Listxml.Slot
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(Slot.NameKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
|
2023-08-09 21:00:02 -04:00
|
|
|
var slotOptions = item.Read<SlotOption[]>(Slot.SlotOptionKey);
|
2023-08-08 12:04:07 -04:00
|
|
|
slot.SlotOption = slotOptions?.Select(ConvertToListxml)?.ToArray();
|
2023-08-04 22:16:00 -04:00
|
|
|
|
|
|
|
|
return slot;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="SlotOption"/> to <cref="Models.Listxml.SlotOption"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.SlotOption? ConvertToListxml(SlotOption? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var slotOption = new Models.Listxml.SlotOption
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Name = item.ReadString(SlotOption.NameKey),
|
|
|
|
|
DevName = item.ReadString(SlotOption.DevNameKey),
|
|
|
|
|
Default = item.ReadString(SlotOption.DefaultKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return slotOption;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="SoftwareList"/> to <cref="Models.Listxml.SoftwareList"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.SoftwareList? ConvertToListxml(SoftwareList? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var softwareList = new Models.Listxml.SoftwareList
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Tag = item.ReadString(SoftwareList.TagKey),
|
|
|
|
|
Name = item.ReadString(SoftwareList.NameKey),
|
|
|
|
|
Status = item.ReadString(SoftwareList.StatusKey),
|
|
|
|
|
Filter = item.ReadString(SoftwareList.FilterKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return softwareList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Sound"/> to <cref="Models.Listxml.Sound"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Sound? ConvertToListxml(Sound? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var sound = new Models.Listxml.Sound
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Channels = item.ReadString(Sound.ChannelsKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return sound;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
/// Convert from <cref="Video"/> to <cref="Models.Listxml.Video"/>
|
2023-08-04 22:16:00 -04:00
|
|
|
/// </summary>
|
2023-08-09 21:00:02 -04:00
|
|
|
private static Models.Listxml.Video? ConvertToListxml(Video? item)
|
2023-08-04 22:16:00 -04:00
|
|
|
{
|
2023-08-08 12:04:07 -04:00
|
|
|
if (item == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2023-08-04 22:16:00 -04:00
|
|
|
var video = new Models.Listxml.Video
|
|
|
|
|
{
|
2023-08-09 21:00:02 -04:00
|
|
|
Screen = item.ReadString(Video.ScreenKey),
|
|
|
|
|
Orientation = item.ReadString(Video.OrientationKey),
|
|
|
|
|
Width = item.ReadString(Video.WidthKey),
|
|
|
|
|
Height = item.ReadString(Video.HeightKey),
|
|
|
|
|
AspectX = item.ReadString(Video.AspectXKey),
|
|
|
|
|
AspectY = item.ReadString(Video.AspectYKey),
|
|
|
|
|
Refresh = item.ReadString(Video.RefreshKey),
|
2023-08-04 22:16:00 -04:00
|
|
|
};
|
|
|
|
|
return video;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|