using System.Collections.Generic; using System.Linq; using SabreTools.Models.Internal; namespace SabreTools.Serialization { /// /// Serializer for Listxml models to internal structure /// public partial class Internal { #region Serialize /// /// Convert from to /// public static Header ConvertHeaderFromListxml(Models.Listxml.M1 item) { var header = new Header { [Header.VersionKey] = item.Version, }; return header; } /// /// Convert from to /// public static Header ConvertHeaderFromListxml(Models.Listxml.Mame item) { var header = new Header { [Header.BuildKey] = item.Build, [Header.DebugKey] = item.Debug, [Header.MameConfigKey] = item.MameConfig, }; return header; } /// /// Convert from to /// public static Machine ConvertMachineFromListxml(Models.Listxml.GameBase item) { var machine = new Machine { [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, }; if (item.BiosSet != null && item.BiosSet.Any()) { var biosSets = new List(); foreach (var biosSet in item.BiosSet) { biosSets.Add(ConvertFromListxml(biosSet)); } machine[Machine.BiosSetKey] = biosSets.ToArray(); } if (item.Rom != null && item.Rom.Any()) { var roms = new List(); foreach (var rom in item.Rom) { roms.Add(ConvertFromListxml(rom)); } machine[Machine.RomKey] = roms.ToArray(); } if (item.Disk != null && item.Disk.Any()) { var disks = new List(); foreach (var disk in item.Disk) { disks.Add(ConvertFromListxml(disk)); } machine[Machine.DiskKey] = disks.ToArray(); } if (item.DeviceRef != null && item.DeviceRef.Any()) { var deviceRefs = new List(); foreach (var deviceRef in item.DeviceRef) { deviceRefs.Add(ConvertFromListxml(deviceRef)); } machine[Machine.DeviceRefKey] = deviceRefs.ToArray(); } if (item.Sample != null && item.Sample.Any()) { var samples = new List(); foreach (var sample in item.Sample) { samples.Add(ConvertFromListxml(sample)); } machine[Machine.SampleKey] = samples.ToArray(); } if (item.Chip != null && item.Chip.Any()) { var chips = new List(); foreach (var chip in item.Chip) { chips.Add(ConvertFromListxml(chip)); } machine[Machine.ChipKey] = chips.ToArray(); } if (item.Display != null && item.Display.Any()) { var displays = new List(); foreach (var display in item.Display) { displays.Add(ConvertFromListxml(display)); } machine[Machine.DisplayKey] = displays.ToArray(); } if (item.Video != null && item.Video.Any()) { var videos = new List