mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile] Simplify merging code
This commit is contained in:
@@ -545,63 +545,11 @@ namespace SabreTools.Library.DatFiles
|
|||||||
List<DatItem> parentItems = this[parent];
|
List<DatItem> parentItems = this[parent];
|
||||||
foreach (DatItem item in parentItems)
|
foreach (DatItem item in parentItems)
|
||||||
{
|
{
|
||||||
// Figure out the type of the item and add it accordingly
|
DatItem datItem = (DatItem)item.Clone();
|
||||||
switch (item.Type)
|
datItem.CopyMachineInformation(copyFrom);
|
||||||
|
if (this[game].Where(i => i.Name == datItem.Name).Count() == 0 && !this[game].Contains(datItem))
|
||||||
{
|
{
|
||||||
case ItemType.Archive:
|
Add(game, datItem);
|
||||||
Archive archive = ((Archive)item).Clone() as Archive;
|
|
||||||
archive.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == archive.Name).Count() == 0 && !this[game].Contains(archive))
|
|
||||||
{
|
|
||||||
Add(game, archive);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.BiosSet:
|
|
||||||
BiosSet biosSet = ((BiosSet)item).Clone() as BiosSet;
|
|
||||||
biosSet.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == biosSet.Name).Count() == 0 && !this[game].Contains(biosSet))
|
|
||||||
{
|
|
||||||
Add(game, biosSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.Disk:
|
|
||||||
Disk disk = ((Disk)item).Clone() as Disk;
|
|
||||||
disk.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == disk.Name).Count() == 0 && !this[game].Contains(disk))
|
|
||||||
{
|
|
||||||
Add(game, disk);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.Release:
|
|
||||||
Release release = ((Release)item).Clone() as Release;
|
|
||||||
release.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == release.Name).Count() == 0 && !this[game].Contains(release))
|
|
||||||
{
|
|
||||||
Add(game, release);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.Rom:
|
|
||||||
Rom rom = ((Rom)item).Clone() as Rom;
|
|
||||||
rom.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == rom.Name).Count() == 0 && !this[game].Contains(rom))
|
|
||||||
{
|
|
||||||
Add(game, rom);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.Sample:
|
|
||||||
Sample sample = ((Sample)item).Clone() as Sample;
|
|
||||||
sample.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == sample.Name).Count() == 0 && !this[game].Contains(sample))
|
|
||||||
{
|
|
||||||
Add(game, sample);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -636,63 +584,11 @@ namespace SabreTools.Library.DatFiles
|
|||||||
List<DatItem> devItems = this[device];
|
List<DatItem> devItems = this[device];
|
||||||
foreach (DatItem item in devItems)
|
foreach (DatItem item in devItems)
|
||||||
{
|
{
|
||||||
// Figure out the type of the item and add it accordingly
|
DatItem datItem = (DatItem)item.Clone();
|
||||||
switch (item.Type)
|
datItem.CopyMachineInformation(copyFrom);
|
||||||
|
if (this[game].Where(i => i.Name == datItem.Name).Count() == 0 && !this[game].Contains(datItem))
|
||||||
{
|
{
|
||||||
case ItemType.Archive:
|
Add(game, datItem);
|
||||||
Archive archive = ((Archive)item).Clone() as Archive;
|
|
||||||
archive.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == archive.Name).Count() == 0 && !this[game].Contains(archive))
|
|
||||||
{
|
|
||||||
Add(game, archive);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.BiosSet:
|
|
||||||
BiosSet biosSet = ((BiosSet)item).Clone() as BiosSet;
|
|
||||||
biosSet.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == biosSet.Name).Count() == 0 && !this[game].Contains(biosSet))
|
|
||||||
{
|
|
||||||
Add(game, biosSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.Disk:
|
|
||||||
Disk disk = ((Disk)item).Clone() as Disk;
|
|
||||||
disk.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == disk.Name).Count() == 0 && !this[game].Contains(disk))
|
|
||||||
{
|
|
||||||
Add(game, disk);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.Release:
|
|
||||||
Release release = ((Release)item).Clone() as Release;
|
|
||||||
release.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == release.Name).Count() == 0 && !this[game].Contains(release))
|
|
||||||
{
|
|
||||||
Add(game, release);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.Rom:
|
|
||||||
Rom rom = ((Rom)item).Clone() as Rom;
|
|
||||||
rom.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == rom.Name).Count() == 0 && !this[game].Contains(rom))
|
|
||||||
{
|
|
||||||
Add(game, rom);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.Sample:
|
|
||||||
Sample sample = ((Sample)item).Clone() as Sample;
|
|
||||||
sample.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == sample.Name).Count() == 0 && !this[game].Contains(sample))
|
|
||||||
{
|
|
||||||
Add(game, sample);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -737,63 +633,11 @@ namespace SabreTools.Library.DatFiles
|
|||||||
List<DatItem> parentItems = this[parent];
|
List<DatItem> parentItems = this[parent];
|
||||||
foreach (DatItem item in parentItems)
|
foreach (DatItem item in parentItems)
|
||||||
{
|
{
|
||||||
// Figure out the type of the item and add it accordingly
|
DatItem datItem = (DatItem)item.Clone();
|
||||||
switch (item.Type)
|
datItem.CopyMachineInformation(copyFrom);
|
||||||
|
if (this[game].Where(i => i.Name == datItem.Name).Count() == 0 && !this[game].Contains(datItem))
|
||||||
{
|
{
|
||||||
case ItemType.Archive:
|
Add(game, datItem);
|
||||||
Archive archive = ((Archive)item).Clone() as Archive;
|
|
||||||
archive.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == archive.Name).Count() == 0 && !this[game].Contains(archive))
|
|
||||||
{
|
|
||||||
Add(game, archive);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.BiosSet:
|
|
||||||
BiosSet biosSet = ((BiosSet)item).Clone() as BiosSet;
|
|
||||||
biosSet.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == biosSet.Name).Count() == 0 && !this[game].Contains(biosSet))
|
|
||||||
{
|
|
||||||
Add(game, biosSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.Disk:
|
|
||||||
Disk disk = ((Disk)item).Clone() as Disk;
|
|
||||||
disk.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == disk.Name).Count() == 0 && !this[game].Contains(disk))
|
|
||||||
{
|
|
||||||
Add(game, disk);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.Release:
|
|
||||||
Release release = ((Release)item).Clone() as Release;
|
|
||||||
release.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == release.Name).Count() == 0 && !this[game].Contains(release))
|
|
||||||
{
|
|
||||||
Add(game, release);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.Rom:
|
|
||||||
Rom rom = ((Rom)item).Clone() as Rom;
|
|
||||||
rom.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == rom.Name).Count() == 0 && !this[game].Contains(rom))
|
|
||||||
{
|
|
||||||
Add(game, rom);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ItemType.Sample:
|
|
||||||
Sample sample = ((Sample)item).Clone() as Sample;
|
|
||||||
sample.CopyMachineInformation(copyFrom);
|
|
||||||
if (this[game].Where(i => i.Name == sample.Name).Count() == 0 && !this[game].Contains(sample))
|
|
||||||
{
|
|
||||||
Add(game, sample);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -914,34 +758,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
List<DatItem> parentItems = this[parent];
|
List<DatItem> parentItems = this[parent];
|
||||||
foreach (DatItem item in parentItems)
|
foreach (DatItem item in parentItems)
|
||||||
{
|
{
|
||||||
// Figure out the type of the item and remove it accordingly
|
DatItem datItem = (DatItem)item.Clone();
|
||||||
switch (item.Type)
|
Remove(game, datItem);
|
||||||
{
|
|
||||||
case ItemType.Archive:
|
|
||||||
Archive archive = ((Archive)item).Clone() as Archive;
|
|
||||||
Remove(game, archive);
|
|
||||||
break;
|
|
||||||
case ItemType.BiosSet:
|
|
||||||
BiosSet biosSet = ((BiosSet)item).Clone() as BiosSet;
|
|
||||||
Remove(game, biosSet);
|
|
||||||
break;
|
|
||||||
case ItemType.Disk:
|
|
||||||
Disk disk = ((Disk)item).Clone() as Disk;
|
|
||||||
Remove(game, disk);
|
|
||||||
break;
|
|
||||||
case ItemType.Release:
|
|
||||||
Release release = ((Release)item).Clone() as Release;
|
|
||||||
Remove(game, release);
|
|
||||||
break;
|
|
||||||
case ItemType.Rom:
|
|
||||||
Rom rom = ((Rom)item).Clone() as Rom;
|
|
||||||
Remove(game, rom);
|
|
||||||
break;
|
|
||||||
case ItemType.Sample:
|
|
||||||
Sample sample = ((Sample)item).Clone() as Sample;
|
|
||||||
Remove(game, sample);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -983,34 +801,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
List<DatItem> parentItems = this[parent];
|
List<DatItem> parentItems = this[parent];
|
||||||
foreach (DatItem item in parentItems)
|
foreach (DatItem item in parentItems)
|
||||||
{
|
{
|
||||||
// Figure out the type of the item and remove it accordingly
|
DatItem datItem = (DatItem)item.Clone();
|
||||||
switch (item.Type)
|
Remove(game, datItem);
|
||||||
{
|
|
||||||
case ItemType.Archive:
|
|
||||||
Archive archive = ((Archive)item).Clone() as Archive;
|
|
||||||
Remove(game, archive);
|
|
||||||
break;
|
|
||||||
case ItemType.BiosSet:
|
|
||||||
BiosSet biosSet = ((BiosSet)item).Clone() as BiosSet;
|
|
||||||
Remove(game, biosSet);
|
|
||||||
break;
|
|
||||||
case ItemType.Disk:
|
|
||||||
Disk disk = ((Disk)item).Clone() as Disk;
|
|
||||||
Remove(game, disk);
|
|
||||||
break;
|
|
||||||
case ItemType.Release:
|
|
||||||
Release release = ((Release)item).Clone() as Release;
|
|
||||||
Remove(game, release);
|
|
||||||
break;
|
|
||||||
case ItemType.Rom:
|
|
||||||
Rom rom = ((Rom)item).Clone() as Rom;
|
|
||||||
Remove(game, rom);
|
|
||||||
break;
|
|
||||||
case ItemType.Sample:
|
|
||||||
Sample sample = ((Sample)item).Clone() as Sample;
|
|
||||||
Remove(game, sample);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we want to get the parent romof tag and put it in each of the items
|
// Now we want to get the parent romof tag and put it in each of the items
|
||||||
|
|||||||
@@ -1283,7 +1283,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove a key from the file dictionary
|
/// Remove a key from the file dictionary if it exists
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">Key in the dictionary to remove</param>
|
/// <param name="key">Key in the dictionary to remove</param>
|
||||||
public void Remove(string key)
|
public void Remove(string key)
|
||||||
@@ -1314,7 +1314,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove a value from the file dictionary
|
/// Remove a value from the file dictionary if it exists
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">Key in the dictionary to remove from</param>
|
/// <param name="key">Key in the dictionary to remove from</param>
|
||||||
/// <param name="value">Value to remove from the dictionary</param>
|
/// <param name="value">Value to remove from the dictionary</param>
|
||||||
@@ -1346,7 +1346,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove a range of values from the file dictionary
|
/// Remove a range of values from the file dictionary if they exists
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">Key in the dictionary to remove from</param>
|
/// <param name="key">Key in the dictionary to remove from</param>
|
||||||
/// <param name="value">Value to remove from the dictionary</param>
|
/// <param name="value">Value to remove from the dictionary</param>
|
||||||
|
|||||||
Reference in New Issue
Block a user