using System.Linq;
namespace SabreTools.DatFiles
{
// TODO: Convert nested items (e.g. Configuration, DipLocation)
// TODO: Determine which items need to have their values flipped (e.g. Part, DiskArea, DataArea)
public partial class DatFile
{
#region Converters
///
/// Convert metadata information
///
/// Metadata file to convert
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
public void ConvertMetadata(Models.Metadata.MetadataFile? item, string filename, int indexId, bool statsOnly)
{
// If the metadata file is invalid, we can't do anything
if (item == null || !item.Any())
return;
// TODO: Add header parsing
// Get the machines from the metadata
var machines = ReadItemArray(item, Models.Metadata.MetadataFile.MachineKey);
if (machines == null)
return;
// Loop through the machines and add
foreach (var machine in machines)
{
ConvertMachine(machine, filename, indexId, statsOnly);
}
}
///
/// Convert machine information
///
/// Metadata file to convert
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ConvertMachine(Models.Metadata.Machine? item, string filename, int indexId, bool statsOnly)
{
// If the machine is invalid, we can't do anything
if (item == null || !item.Any())
return;
// Create an internal machine
var machine = new DatItems.Machine(item);
// Convert items in the machine
if (item.ContainsKey(Models.Metadata.Machine.AdjusterKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.AdjusterKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.ArchiveKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.ArchiveKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.BiosSetKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.BiosSetKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.ChipKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.ChipKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.ConfigurationKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.ConfigurationKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.DeviceKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.DeviceKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.DeviceRefKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.DeviceRefKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.DipSwitchKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.DipSwitchKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.DiskKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.DiskKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.DisplayKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.DisplayKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.DriverKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.DriverKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.DumpKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.DumpKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.FeatureKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.FeatureKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.InfoKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.InfoKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.InputKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.InputKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.MediaKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.MediaKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.PartKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.PartKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.PortKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.PortKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.RamOptionKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.RamOptionKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.ReleaseKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.ReleaseKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.RomKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.RomKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.SampleKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.SampleKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.SharedFeatKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.SharedFeatKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.SoftwareListKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.SoftwareListKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.SoundKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.SoundKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
if (item.ContainsKey(Models.Metadata.Machine.TruripKey))
{
// TODO: Figure out what this maps to
}
if (item.ContainsKey(Models.Metadata.Machine.VideoKey))
{
var items = ReadItemArray(item, Models.Metadata.Machine.VideoKey);
ProcessItems(items, machine, filename, indexId, statsOnly);
}
}
///
/// Read an item array from a given key, if possible
///
private static T[]? ReadItemArray(Models.Metadata.DictionaryBase item, string key) where T : Models.Metadata.DictionaryBase
{
var items = item.Read(key);
if (items == default)
{
var single = item.Read(key);
if (single != default)
items = [single];
}
return items;
}
///
/// Convert Adjuster information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Adjuster[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Adjuster(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Archive information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Archive[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Archive(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert BiosSet information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.BiosSet[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.BiosSet(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Chip information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Chip[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Chip(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Configuration information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Configuration[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Configuration(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert DataArea information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.DataArea[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// TODO: Extract Roms
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.DataArea(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Device information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Device[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Device(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert DeviceRef information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.DeviceRef[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.DeviceReference(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert DipLocation information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.DipLocation[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.DipLocation(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert DipSwitch information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.DipSwitch[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.DipSwitch(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert DipValue information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.DipValue[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.DipValue(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Disk information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Disk[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Disk(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert DiskArea information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.DiskArea[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// TODO: Extract Disks
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.DiskArea(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Display information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Display[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Display(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Driver information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Driver[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Driver(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Dump information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Dump[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
// TODO: Handle processing of Dump items (rom, megarom, sccpluscart)
}
}
///
/// Convert Feature information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Feature[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Feature(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Info information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Info[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Info(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Input information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Input[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Input(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Media information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Media[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Media(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Part information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Part[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// TODO: Extract DataAreas
// TODO: Extract DiskAreas
// TODO: Extract DipSwitches
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Part(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Port information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Port[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Port(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert RamOption information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.RamOption[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.RamOption(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Release information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Release[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Release(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Rom information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Rom[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Rom(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Sample information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Sample[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Sample(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert SharedFeat information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.SharedFeat[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.SharedFeature(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert SoftwareList information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.SoftwareList[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.SoftwareList(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Sound information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Sound[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Sound(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
///
/// Convert Video information
///
/// Array of internal items to convert
/// Machine to use with the converted items
/// Name of the file to be parsed
/// Index ID for the DAT
/// True to only add item statistics while parsing, false otherwise
private void ProcessItems(Models.Metadata.Video[]? items, DatItems.Machine machine, string filename, int indexId, bool statsOnly)
{
// If the array is null or empty, return without processing
if (items == null || items.Length == 0)
return;
// Loop through the items and add
foreach (var item in items)
{
var datItem = new DatItems.Formats.Display(item)
{
Source = new DatItems.Source { Index = indexId, Name = filename }
};
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem, statsOnly);
}
}
#endregion
}
}