Move field replacement

This commit is contained in:
Matt Nadareski
2020-08-17 22:35:17 -07:00
parent 5660da7b0e
commit 42b3bd906a
6 changed files with 327 additions and 348 deletions

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Security.Permissions;
using Newtonsoft.Json;
namespace SabreTools.Library.DatItems
@@ -135,5 +134,34 @@ namespace SabreTools.Library.DatItems
}
#endregion
#region Sorting and Merging
/// <summary>
/// Replace fields from another item
/// </summary>
/// <param name="item">DatItem to pull new information from</param>
/// <param name="updateFields">List of Fields representing what should be updated</param>
public override void ReplaceFields(DatItem item, List<Field> updateFields)
{
// Replace common fields first
base.ReplaceFields(item, updateFields);
// If we don't have a BiosSet to replace from, ignore specific fields
if (item.ItemType != ItemType.BiosSet)
return;
// Cast for easier access
BiosSet newItem = item as BiosSet;
// Replace the fields
if (updateFields.Contains(Field.BiosDescription))
Description = newItem.Description;
if (updateFields.Contains(Field.Default))
Default = newItem.Default;
}
#endregion
}
}