mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Consolidate removal code
This commit is contained in:
@@ -392,19 +392,28 @@ namespace SabreTools.DatItems
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove a field from the DatItem
|
/// Remove a field from the DatItem
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="datItemField">Item field to remove</param>
|
/// <param name="fieldName">Field to remove</param>
|
||||||
/// <returns>True if the removal was successful, false otherwise</returns>
|
/// <returns>True if the removal was successful, false otherwise</returns>
|
||||||
public abstract bool RemoveField(DatItemField datItemField);
|
public bool RemoveField(string? fieldName) => FieldManipulator.RemoveField(_internal, fieldName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set a field in the DatItem from a mapping string
|
/// Set a field in the DatItem from a mapping string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="machineField">Item field to set</param>
|
/// <param name="fieldName">Item field to set</param>
|
||||||
/// <param name="value">String representing the value to set</param>
|
/// <param name="value">String representing the value to set</param>
|
||||||
/// <returns>True if the setting was successful, false otherwise</returns>
|
/// <returns>True if the setting was successful, false otherwise</returns>
|
||||||
/// <remarks>This only performs minimal validation before setting</remarks>
|
/// <remarks>This only performs minimal validation before setting</remarks>
|
||||||
public abstract bool SetField(DatItemField datItemField, string value);
|
public abstract bool SetField(DatItemField datItemField, string value);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set a field in the DatItem from a mapping string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fieldName">Field to set</param>
|
||||||
|
/// <param name="value">String representing the value to set</param>
|
||||||
|
/// <returns>True if the removal was successful, false otherwise</returns>
|
||||||
|
/// <remarks>This only performs minimal validation before setting</remarks>
|
||||||
|
public bool SetField(string? fieldName, string value) => FieldManipulator.SetField(_internal, fieldName, value);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Sorting and Merging
|
#region Sorting and Merging
|
||||||
|
|||||||
@@ -101,20 +101,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Default => Models.Metadata.Adjuster.DefaultKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,20 +62,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Analog_Mask => Models.Metadata.Analog.MaskKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -138,19 +138,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -96,21 +96,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Default => Models.Metadata.BiosSet.DefaultKey,
|
|
||||||
DatItemField.Description => Models.Metadata.BiosSet.DescriptionKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,9 +60,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField) => true;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value) => true;
|
public override bool SetField(DatItemField datItemField, string value) => true;
|
||||||
|
|
||||||
|
|||||||
@@ -112,22 +112,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.ChipType => Models.Metadata.Chip.ChipTypeKey,
|
|
||||||
DatItemField.Clock => Models.Metadata.Chip.ClockKey,
|
|
||||||
DatItemField.Tag => Models.Metadata.Chip.TagKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -98,27 +98,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Mask => Models.Metadata.Condition.MaskKey,
|
|
||||||
DatItemField.Condition_Mask => Models.Metadata.Condition.MaskKey,
|
|
||||||
DatItemField.Relation => Models.Metadata.Condition.RelationKey,
|
|
||||||
DatItemField.Condition_Relation => Models.Metadata.Condition.RelationKey,
|
|
||||||
DatItemField.Tag => Models.Metadata.Condition.TagKey,
|
|
||||||
DatItemField.Condition_Tag => Models.Metadata.Condition.TagKey,
|
|
||||||
DatItemField.Value => Models.Metadata.Condition.ValueKey,
|
|
||||||
DatItemField.Condition_Value => Models.Metadata.Condition.ValueKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -99,23 +99,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Inverted => Models.Metadata.ConfLocation.InvertedKey,
|
|
||||||
DatItemField.Location_Inverted => Models.Metadata.ConfLocation.InvertedKey,
|
|
||||||
DatItemField.Number => Models.Metadata.ConfLocation.NumberKey,
|
|
||||||
DatItemField.Location_Number => Models.Metadata.ConfLocation.NumberKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -111,23 +111,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Default => Models.Metadata.ConfSetting.DefaultKey,
|
|
||||||
DatItemField.Setting_Default => Models.Metadata.ConfSetting.DefaultKey,
|
|
||||||
DatItemField.Value => Models.Metadata.ConfSetting.ValueKey,
|
|
||||||
DatItemField.Setting_Value => Models.Metadata.ConfSetting.ValueKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -134,21 +134,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Mask => Models.Metadata.Configuration.MaskKey,
|
|
||||||
DatItemField.Tag => Models.Metadata.Configuration.TagKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -202,31 +202,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Control_Buttons => Models.Metadata.Control.ButtonsKey,
|
|
||||||
DatItemField.Control_KeyDelta => Models.Metadata.Control.KeyDeltaKey,
|
|
||||||
DatItemField.Control_Maximum => Models.Metadata.Control.MaximumKey,
|
|
||||||
DatItemField.Control_Minimum => Models.Metadata.Control.MinimumKey,
|
|
||||||
DatItemField.Control_Player => Models.Metadata.Control.PlayerKey,
|
|
||||||
DatItemField.Control_RequiredButtons => Models.Metadata.Control.ReqButtonsKey,
|
|
||||||
DatItemField.Control_Reverse => Models.Metadata.Control.ReverseKey,
|
|
||||||
DatItemField.Control_Sensitivity => Models.Metadata.Control.SensitivityKey,
|
|
||||||
DatItemField.Control_Type => Models.Metadata.Control.ControlTypeKey,
|
|
||||||
DatItemField.Control_Ways => Models.Metadata.Control.WaysKey,
|
|
||||||
DatItemField.Control_Ways2 => Models.Metadata.Control.Ways2Key,
|
|
||||||
DatItemField.Control_Ways3 => Models.Metadata.Control.Ways3Key,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -114,22 +114,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.AreaEndianness => Models.Metadata.DataArea.EndiannessKey,
|
|
||||||
DatItemField.AreaSize => Models.Metadata.DataArea.SizeKey,
|
|
||||||
DatItemField.AreaWidth => Models.Metadata.DataArea.WidthKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -140,24 +140,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.DeviceType => Models.Metadata.Device.DeviceTypeKey,
|
|
||||||
DatItemField.FixedImage => Models.Metadata.Device.FixedImageKey,
|
|
||||||
DatItemField.Interface => Models.Metadata.Device.InterfaceKey,
|
|
||||||
DatItemField.Mandatory => Models.Metadata.Device.MandatoryKey,
|
|
||||||
DatItemField.Tag => Models.Metadata.Device.TagKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,19 +73,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -99,23 +99,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Inverted => Models.Metadata.DipLocation.InvertedKey,
|
|
||||||
DatItemField.Location_Inverted => Models.Metadata.DipLocation.InvertedKey,
|
|
||||||
DatItemField.Number => Models.Metadata.DipLocation.NumberKey,
|
|
||||||
DatItemField.Location_Number => Models.Metadata.DipLocation.NumberKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -162,21 +162,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Mask => Models.Metadata.DipSwitch.MaskKey,
|
|
||||||
DatItemField.Tag => Models.Metadata.DipSwitch.TagKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -111,23 +111,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Default => Models.Metadata.DipValue.DefaultKey,
|
|
||||||
DatItemField.Setting_Default => Models.Metadata.DipValue.DefaultKey,
|
|
||||||
DatItemField.Value => Models.Metadata.DipValue.ValueKey,
|
|
||||||
DatItemField.Setting_Value => Models.Metadata.DipValue.ValueKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -288,27 +288,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Index => Models.Metadata.Disk.IndexKey,
|
|
||||||
DatItemField.MD5 => Models.Metadata.Disk.MD5Key,
|
|
||||||
DatItemField.Merge => Models.Metadata.Disk.MergeKey,
|
|
||||||
DatItemField.Optional => Models.Metadata.Disk.OptionalKey,
|
|
||||||
DatItemField.Region => Models.Metadata.Disk.RegionKey,
|
|
||||||
DatItemField.SHA1 => Models.Metadata.Disk.SHA1Key,
|
|
||||||
DatItemField.Status => Models.Metadata.Disk.StatusKey,
|
|
||||||
DatItemField.Writable => Models.Metadata.Disk.WritableKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -74,19 +74,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -234,33 +234,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.DisplayType => Models.Metadata.Display.DisplayTypeKey,
|
|
||||||
DatItemField.FlipX => Models.Metadata.Display.FlipXKey,
|
|
||||||
DatItemField.HBEnd => Models.Metadata.Display.HBEndKey,
|
|
||||||
DatItemField.HBStart => Models.Metadata.Display.HBStartKey,
|
|
||||||
DatItemField.Height => Models.Metadata.Display.HeightKey,
|
|
||||||
DatItemField.HTotal => Models.Metadata.Display.HTotalKey,
|
|
||||||
DatItemField.PixClock => Models.Metadata.Display.PixClockKey,
|
|
||||||
DatItemField.Refresh => Models.Metadata.Display.RefreshKey,
|
|
||||||
DatItemField.Rotate => Models.Metadata.Display.RotateKey,
|
|
||||||
DatItemField.Tag => Models.Metadata.Display.TagKey,
|
|
||||||
DatItemField.VBEnd => Models.Metadata.Display.VBEndKey,
|
|
||||||
DatItemField.VBStart => Models.Metadata.Display.VBStartKey,
|
|
||||||
DatItemField.VTotal => Models.Metadata.Display.VTotalKey,
|
|
||||||
DatItemField.Width => Models.Metadata.Display.WidthKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -165,27 +165,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.CocktailStatus => Models.Metadata.Driver.CocktailKey,
|
|
||||||
DatItemField.EmulationStatus => Models.Metadata.Driver.EmulationKey,
|
|
||||||
DatItemField.Incomplete => Models.Metadata.Driver.IncompleteKey,
|
|
||||||
DatItemField.NoSoundHardware => Models.Metadata.Driver.NoSoundHardwareKey,
|
|
||||||
DatItemField.RequiresArtwork => Models.Metadata.Driver.RequiresArtworkKey,
|
|
||||||
DatItemField.SaveStateStatus => Models.Metadata.Driver.SaveStateKey,
|
|
||||||
DatItemField.SupportStatus => Models.Metadata.Driver.StatusKey,
|
|
||||||
DatItemField.Unofficial => Models.Metadata.Driver.UnofficialKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,19 +73,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -96,22 +96,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.FeatureOverall => Models.Metadata.Feature.OverallKey,
|
|
||||||
DatItemField.FeatureStatus => Models.Metadata.Feature.StatusKey,
|
|
||||||
DatItemField.FeatureType => Models.Metadata.Feature.FeatureTypeKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -328,20 +328,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
// TODO: Figure out what fields go here
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,20 +83,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Value => Models.Metadata.Info.ValueKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -119,23 +119,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Coins => Models.Metadata.Input.CoinsKey,
|
|
||||||
DatItemField.Players => Models.Metadata.Input.PlayersKey,
|
|
||||||
DatItemField.Service => Models.Metadata.Input.ServiceKey,
|
|
||||||
DatItemField.Tilt => Models.Metadata.Input.TiltKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,20 +83,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Instance_BriefName => Models.Metadata.Instance.BriefNameKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -186,23 +186,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.MD5 => Models.Metadata.Media.MD5Key,
|
|
||||||
DatItemField.SHA1 => Models.Metadata.Media.SHA1Key,
|
|
||||||
DatItemField.SHA256 => Models.Metadata.Media.SHA256Key,
|
|
||||||
DatItemField.SpamSum => Models.Metadata.Media.SpamSumKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -90,20 +90,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Part_Interface => Models.Metadata.Part.InterfaceKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,21 +83,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Value => Models.Metadata.Feature.ValueKey,
|
|
||||||
DatItemField.Part_Feature_Value => Models.Metadata.Feature.ValueKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,20 +77,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Tag => Models.Metadata.Port.TagKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -96,21 +96,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Content => Models.Metadata.RamOption.ContentKey,
|
|
||||||
DatItemField.Default => Models.Metadata.RamOption.DefaultKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -120,23 +120,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Date => Models.Metadata.Release.DateKey,
|
|
||||||
DatItemField.Default => Models.Metadata.Release.DefaultKey,
|
|
||||||
DatItemField.Language => Models.Metadata.Release.LanguageKey,
|
|
||||||
DatItemField.Region => Models.Metadata.Release.RegionKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -190,20 +190,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
// TODO: Figure out what fields go here
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -599,60 +599,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.AltName => Models.Metadata.Rom.AltRomnameKey,
|
|
||||||
DatItemField.AltTitle => Models.Metadata.Rom.AltTitleKey,
|
|
||||||
DatItemField.ArchiveDotOrgFormat => Models.Metadata.Rom.FormatKey,
|
|
||||||
DatItemField.ArchiveDotOrgSource => Models.Metadata.Rom.SourceKey,
|
|
||||||
DatItemField.Bios => Models.Metadata.Rom.BiosKey,
|
|
||||||
//DatItemField.Boot => Models.Metadata.Rom.BootKey,
|
|
||||||
DatItemField.CRC => Models.Metadata.Rom.CRCKey,
|
|
||||||
DatItemField.Date => Models.Metadata.Rom.DateKey,
|
|
||||||
DatItemField.Inverted => Models.Metadata.Rom.InvertedKey,
|
|
||||||
DatItemField.LoadFlag => Models.Metadata.Rom.LoadFlagKey,
|
|
||||||
DatItemField.MD5 => Models.Metadata.Rom.MD5Key,
|
|
||||||
DatItemField.Merge => Models.Metadata.Rom.MergeKey,
|
|
||||||
DatItemField.MIA => Models.Metadata.Rom.MIAKey,
|
|
||||||
DatItemField.Offset => Models.Metadata.Rom.OffsetKey,
|
|
||||||
DatItemField.OpenMSXSubType => Models.Metadata.Rom.OpenMSXMediaType, // TODO: Fix with Key suffix
|
|
||||||
DatItemField.OpenMSXType => Models.Metadata.Rom.OpenMSXType, // TODO: Fix with Key suffix
|
|
||||||
DatItemField.Optional => Models.Metadata.Rom.OptionalKey,
|
|
||||||
//DatItemField.Original => Models.Metadata.Rom.OriginalKey,
|
|
||||||
DatItemField.OriginalFilename => Models.Metadata.Rom.OriginalKey,
|
|
||||||
DatItemField.Region => Models.Metadata.Rom.RegionKey,
|
|
||||||
DatItemField.Remark => Models.Metadata.Rom.RemarkKey,
|
|
||||||
DatItemField.Rotation => Models.Metadata.Rom.RotationKey,
|
|
||||||
DatItemField.SHA1 => Models.Metadata.Rom.SHA1Key,
|
|
||||||
DatItemField.SHA256 => Models.Metadata.Rom.SHA256Key,
|
|
||||||
DatItemField.SHA384 => Models.Metadata.Rom.SHA384Key,
|
|
||||||
DatItemField.SHA512 => Models.Metadata.Rom.SHA512Key,
|
|
||||||
DatItemField.Size => Models.Metadata.Rom.SizeKey,
|
|
||||||
DatItemField.SpamSum => Models.Metadata.Rom.SpamSumKey,
|
|
||||||
DatItemField.Status => Models.Metadata.Rom.StatusKey,
|
|
||||||
DatItemField.Summation => Models.Metadata.Rom.SummationKey,
|
|
||||||
DatItemField.Value => Models.Metadata.Rom.ValueKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// A null value means special handling is needed
|
|
||||||
if (fieldName == null)
|
|
||||||
{
|
|
||||||
switch (datItemField)
|
|
||||||
{
|
|
||||||
case DatItemField.Boot: Boot = null; return true;
|
|
||||||
case DatItemField.Original: Original = null; return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,19 +73,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -178,20 +178,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
// TODO: Figure out what fields go here
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,20 +83,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Value => Models.Metadata.SharedFeat.ValueKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,19 +88,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -96,22 +96,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Default => Models.Metadata.SlotOption.DefaultKey,
|
|
||||||
DatItemField.SlotOption_Default => Models.Metadata.SlotOption.DefaultKey,
|
|
||||||
DatItemField.SlotOption_DeviceName => Models.Metadata.SlotOption.DevNameKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -115,22 +115,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Filter => Models.Metadata.SoftwareList.FilterKey,
|
|
||||||
DatItemField.SoftwareListStatus => Models.Metadata.SoftwareList.StatusKey,
|
|
||||||
DatItemField.Tag => Models.Metadata.SoftwareList.TagKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -65,20 +65,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
DatItemField.Default => Models.Metadata.Sound.ChannelsKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -228,20 +228,6 @@ namespace SabreTools.DatItems.Formats
|
|||||||
|
|
||||||
#region Manipulation
|
#region Manipulation
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool RemoveField(DatItemField datItemField)
|
|
||||||
{
|
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = datItemField switch
|
|
||||||
{
|
|
||||||
// TODO: Figure out what fields go here
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_internal, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override bool SetField(DatItemField datItemField, string value)
|
public override bool SetField(DatItemField datItemField, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -552,75 +552,10 @@ namespace SabreTools.DatItems
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove a field from the Machine
|
/// Remove a field from the Machine
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="machineField">Machine field to remove</param>
|
/// <param name="fieldName">Field to remove</param>
|
||||||
/// <returns>True if the removal was successful, false otherwise</returns>
|
/// <returns>True if the removal was successful, false otherwise</returns>
|
||||||
public bool RemoveField(MachineField machineField)
|
public bool RemoveField(string? fieldName)
|
||||||
{
|
=> FieldManipulator.RemoveField(_machine, fieldName);
|
||||||
// Get the correct internal field name
|
|
||||||
string? fieldName = machineField switch
|
|
||||||
{
|
|
||||||
MachineField.Board => Models.Metadata.Machine.BoardKey,
|
|
||||||
MachineField.Buttons => Models.Metadata.Machine.ButtonsKey,
|
|
||||||
MachineField.Category => Models.Metadata.Machine.CategoryKey,
|
|
||||||
MachineField.CloneOf => Models.Metadata.Machine.CloneOfKey,
|
|
||||||
MachineField.CloneOfID => Models.Metadata.Machine.CloneOfIdKey,
|
|
||||||
MachineField.Comment => Models.Metadata.Machine.CommentKey,
|
|
||||||
MachineField.Control => Models.Metadata.Machine.ControlKey,
|
|
||||||
MachineField.Country => Models.Metadata.Machine.CountryKey,
|
|
||||||
//MachineField.CRC => Models.Metadata.Machine.CRCKey,
|
|
||||||
MachineField.Description => Models.Metadata.Machine.DescriptionKey,
|
|
||||||
//MachineField.Developer => Models.Metadata.Machine.DeveloperKey,
|
|
||||||
MachineField.DisplayCount => Models.Metadata.Machine.DisplayCountKey,
|
|
||||||
MachineField.DisplayType => Models.Metadata.Machine.DisplayTypeKey,
|
|
||||||
//MachineField.Enabled => Models.Metadata.Machine.EnabledKey,
|
|
||||||
MachineField.GenMSXID => Models.Metadata.Machine.GenMSXIDKey,
|
|
||||||
//MachineField.Genre => Models.Metadata.Machine.GenreKey,
|
|
||||||
MachineField.History => Models.Metadata.Machine.HistoryKey,
|
|
||||||
MachineField.ID => Models.Metadata.Machine.IdKey,
|
|
||||||
MachineField.Manufacturer => Models.Metadata.Machine.ManufacturerKey,
|
|
||||||
MachineField.Name => Models.Metadata.Machine.NameKey,
|
|
||||||
MachineField.Players => Models.Metadata.Machine.PlayersKey,
|
|
||||||
MachineField.Publisher => Models.Metadata.Machine.PublisherKey,
|
|
||||||
//MachineField.Ratings => Models.Metadata.Machine.RatingsKey,
|
|
||||||
MachineField.RebuildTo => Models.Metadata.Machine.RebuildToKey,
|
|
||||||
//MachineField.RelatedTo => Models.Metadata.Machine.RelatedToKey,
|
|
||||||
MachineField.RomOf => Models.Metadata.Machine.RomOfKey,
|
|
||||||
MachineField.Rotation => Models.Metadata.Machine.RotationKey,
|
|
||||||
MachineField.Runnable => Models.Metadata.Machine.RunnableKey,
|
|
||||||
MachineField.SampleOf => Models.Metadata.Machine.SampleOfKey,
|
|
||||||
//MachineField.Score => Models.Metadata.Machine.ScoreKey,
|
|
||||||
MachineField.SourceFile => Models.Metadata.Machine.SourceFileKey,
|
|
||||||
MachineField.Status => Models.Metadata.Machine.StatusKey,
|
|
||||||
//MachineField.Subgenre => Models.Metadata.Machine.SubgenreKey,
|
|
||||||
MachineField.Supported => Models.Metadata.Machine.SupportedKey,
|
|
||||||
MachineField.System => Models.Metadata.Machine.SystemKey,
|
|
||||||
//MachineField.TitleID => Models.Metadata.Machine.TitleIDKey,
|
|
||||||
//MachineField.Type => Models.Metadata.Machine.TypeKey,
|
|
||||||
MachineField.Year => Models.Metadata.Machine.YearKey,
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
// A null value means special handling is needed
|
|
||||||
if (fieldName == null)
|
|
||||||
{
|
|
||||||
switch (machineField)
|
|
||||||
{
|
|
||||||
case MachineField.CRC: Crc = null; return true;
|
|
||||||
case MachineField.Developer: Developer = null; return true;
|
|
||||||
case MachineField.Enabled: Enabled = null; return true;
|
|
||||||
case MachineField.Genre: Genre = null; return true;
|
|
||||||
case MachineField.Ratings: Ratings = null; return true;
|
|
||||||
case MachineField.RelatedTo: RelatedTo = null; return true;
|
|
||||||
case MachineField.Score: Score = null; return true;
|
|
||||||
case MachineField.Subgenre: Subgenre = null; return true;
|
|
||||||
case MachineField.TitleID: TitleID = null; return true;
|
|
||||||
case MachineField.Type: MachineType = MachineType.None; return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the field and return
|
|
||||||
return FieldManipulator.RemoveField(_machine, fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set a field in the Machine from a mapping string
|
/// Set a field in the Machine from a mapping string
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using SabreTools.Models.Metadata;
|
|||||||
|
|
||||||
namespace SabreTools.Filter
|
namespace SabreTools.Filter
|
||||||
{
|
{
|
||||||
internal static class FilterParser
|
public static class FilterParser
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parse a filter ID string into the item name and field name, if possible
|
/// Parse a filter ID string into the item name and field name, if possible
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using SabreTools.Models.Metadata;
|
|||||||
|
|
||||||
namespace SabreTools.Filter
|
namespace SabreTools.Filter
|
||||||
{
|
{
|
||||||
internal static class TypeHelper
|
public static class TypeHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get constant values for the given type, if possible
|
/// Get constant values for the given type, if possible
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.Core.Tools;
|
|
||||||
using SabreTools.DatFiles;
|
|
||||||
|
|
||||||
namespace SabreTools.Filtering
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents the removal operations that need to be performed on a DatHeader
|
|
||||||
/// </summary>
|
|
||||||
public class DatHeaderRemover
|
|
||||||
{
|
|
||||||
#region Fields
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// List of DatHeader fields to exclude from writing
|
|
||||||
/// </summary>
|
|
||||||
public List<DatHeaderField> DatHeaderFields { get; private set; } = new List<DatHeaderField>();
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Population
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Set remover from a value
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="field">Key for the remover to be set</param>
|
|
||||||
public bool SetRemover(string field)
|
|
||||||
{
|
|
||||||
// If the key is null or empty, return false
|
|
||||||
if (string.IsNullOrEmpty(field))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// If we have a DatHeader field
|
|
||||||
DatHeaderField datHeaderField = field.AsDatHeaderField();
|
|
||||||
if (datHeaderField != DatHeaderField.NULL)
|
|
||||||
{
|
|
||||||
DatHeaderFields.Add(datHeaderField);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Running
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="datItem">DatHeader to remove fields from</param>
|
|
||||||
public void RemoveFields(DatHeader datHeader)
|
|
||||||
{
|
|
||||||
if (datHeader == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#region Common
|
|
||||||
|
|
||||||
if (DatHeaderFields == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// TODO: Figure out how to properly implement DatHeader field removal
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,350 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using SabreTools.Core;
|
|
||||||
using SabreTools.Core.Tools;
|
|
||||||
using SabreTools.DatItems;
|
|
||||||
using SabreTools.DatItems.Formats;
|
|
||||||
|
|
||||||
namespace SabreTools.Filtering
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents the removal operations that need to be performed on a set of items, usually a DAT
|
|
||||||
/// </summary>
|
|
||||||
public class DatItemRemover
|
|
||||||
{
|
|
||||||
#region Fields
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// List of Machine fields to exclude from writing
|
|
||||||
/// </summary>
|
|
||||||
public List<MachineField> MachineFields { get; private set; } = new List<MachineField>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// List of DatItem fields to exclude from writing
|
|
||||||
/// </summary>
|
|
||||||
public List<DatItemField> DatItemFields { get; private set; } = new List<DatItemField>();
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Population
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Set remover from a value
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="field">Key for the remover to be set</param>
|
|
||||||
public bool SetRemover(string field)
|
|
||||||
{
|
|
||||||
// If the key is null or empty, return false
|
|
||||||
if (string.IsNullOrEmpty(field))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// If we have a Machine field
|
|
||||||
MachineField machineField = field.AsMachineField();
|
|
||||||
if (machineField != MachineField.NULL)
|
|
||||||
{
|
|
||||||
MachineFields.Add(machineField);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we have a DatItem field
|
|
||||||
DatItemField datItemField = field.AsDatItemField();
|
|
||||||
if (datItemField != DatItemField.NULL)
|
|
||||||
{
|
|
||||||
DatItemFields.Add(datItemField);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Running
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="datItem">DatItem to remove fields from</param>
|
|
||||||
public void RemoveFields(DatItem? datItem)
|
|
||||||
{
|
|
||||||
if (datItem == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#region Common
|
|
||||||
|
|
||||||
if (MachineFields != null && MachineFields.Any() && datItem.Machine != null)
|
|
||||||
RemoveFields(datItem.Machine);
|
|
||||||
|
|
||||||
if (DatItemFields == null || !DatItemFields.Any())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (DatItemFields.Contains(DatItemField.Name))
|
|
||||||
datItem.SetName(null);
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Item-Specific
|
|
||||||
|
|
||||||
// Handle unnested removals first
|
|
||||||
foreach (var datItemField in DatItemFields)
|
|
||||||
{
|
|
||||||
datItem.RemoveField(datItemField);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle nested removals
|
|
||||||
switch (datItem)
|
|
||||||
{
|
|
||||||
case Adjuster adjuster: RemoveFields(adjuster); break;
|
|
||||||
case Configuration configuration: RemoveFields(configuration); break;
|
|
||||||
case ConfSetting confSetting: RemoveFields(confSetting); break;
|
|
||||||
case Device device: RemoveFields(device); break;
|
|
||||||
case DipSwitch dipSwitch: RemoveFields(dipSwitch); break;
|
|
||||||
case DipValue dipValue: RemoveFields(dipValue); break;
|
|
||||||
case Disk disk: RemoveFields(disk); break;
|
|
||||||
case Input input: RemoveFields(input); break;
|
|
||||||
case Part part: RemoveFields(part); break;
|
|
||||||
case Port port: RemoveFields(port); break;
|
|
||||||
case Rom rom: RemoveFields(rom); break;
|
|
||||||
case Slot slot: RemoveFields(slot); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="machine">Machine to remove fields from</param>
|
|
||||||
private void RemoveFields(Machine? machine)
|
|
||||||
{
|
|
||||||
if (machine == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (var machineField in MachineFields)
|
|
||||||
{
|
|
||||||
machine.RemoveField(machineField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="adjuster">Adjuster to remove fields from</param>
|
|
||||||
private void RemoveFields(Adjuster adjuster)
|
|
||||||
{
|
|
||||||
if (!adjuster.ConditionsSpecified)
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (Condition subCondition in adjuster.Conditions!)
|
|
||||||
{
|
|
||||||
RemoveFields(subCondition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="configuration">Configuration to remove fields from</param>
|
|
||||||
private void RemoveFields(Configuration configuration)
|
|
||||||
{
|
|
||||||
if (configuration.ConditionsSpecified)
|
|
||||||
{
|
|
||||||
foreach (Condition subCondition in configuration.Conditions!)
|
|
||||||
{
|
|
||||||
RemoveFields(subCondition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configuration.LocationsSpecified)
|
|
||||||
{
|
|
||||||
foreach (ConfLocation subLocation in configuration.Locations!)
|
|
||||||
{
|
|
||||||
RemoveFields(subLocation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configuration.SettingsSpecified)
|
|
||||||
{
|
|
||||||
foreach (ConfSetting subSetting in configuration.Settings!)
|
|
||||||
{
|
|
||||||
RemoveFields(subSetting as DatItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="confsetting">ConfSetting to remove fields from</param>
|
|
||||||
private void RemoveFields(ConfSetting confsetting)
|
|
||||||
{
|
|
||||||
if (confsetting.ConditionsSpecified)
|
|
||||||
{
|
|
||||||
foreach (Condition subCondition in confsetting.Conditions!)
|
|
||||||
{
|
|
||||||
RemoveFields(subCondition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="device">Device to remove fields from</param>
|
|
||||||
private void RemoveFields(Device device)
|
|
||||||
{
|
|
||||||
if (device.ExtensionsSpecified)
|
|
||||||
{
|
|
||||||
foreach (Extension subExtension in device.Extensions!)
|
|
||||||
{
|
|
||||||
RemoveFields(subExtension);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (device.InstancesSpecified)
|
|
||||||
{
|
|
||||||
foreach (Instance subInstance in device.Instances!)
|
|
||||||
{
|
|
||||||
RemoveFields(subInstance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dipSwitch">DipSwitch to remove fields from</param>
|
|
||||||
private void RemoveFields(DipSwitch dipSwitch)
|
|
||||||
{
|
|
||||||
if (dipSwitch.ConditionsSpecified)
|
|
||||||
{
|
|
||||||
foreach (Condition subCondition in dipSwitch.Conditions!)
|
|
||||||
{
|
|
||||||
RemoveFields(subCondition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dipSwitch.LocationsSpecified)
|
|
||||||
{
|
|
||||||
foreach (DipLocation subLocation in dipSwitch.Locations!)
|
|
||||||
{
|
|
||||||
RemoveFields(subLocation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dipSwitch.ValuesSpecified)
|
|
||||||
{
|
|
||||||
foreach (DipValue subValue in dipSwitch.Values!)
|
|
||||||
{
|
|
||||||
RemoveFields(subValue as DatItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dipSwitch.PartSpecified)
|
|
||||||
RemoveFields(dipSwitch.Part! as DatItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dipValue">DipValue to remove fields from</param>
|
|
||||||
private void RemoveFields(DipValue dipValue)
|
|
||||||
{
|
|
||||||
if (dipValue.ConditionsSpecified)
|
|
||||||
{
|
|
||||||
foreach (Condition subCondition in dipValue.Conditions!)
|
|
||||||
{
|
|
||||||
RemoveFields(subCondition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disk">Disk to remove fields from</param>
|
|
||||||
private void RemoveFields(Disk disk)
|
|
||||||
{
|
|
||||||
if (disk.DiskAreaSpecified)
|
|
||||||
RemoveFields(disk.DiskArea);
|
|
||||||
|
|
||||||
if (disk.PartSpecified)
|
|
||||||
RemoveFields(disk.Part! as DatItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input">Input to remove fields from</param>
|
|
||||||
private void RemoveFields(Input input)
|
|
||||||
{
|
|
||||||
if (input.ControlsSpecified)
|
|
||||||
{
|
|
||||||
foreach (Control subControl in input.Controls!)
|
|
||||||
{
|
|
||||||
RemoveFields(subControl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="part">Part to remove fields from</param>
|
|
||||||
private void RemoveFields(Part part)
|
|
||||||
{
|
|
||||||
if (part.FeaturesSpecified)
|
|
||||||
{
|
|
||||||
foreach (PartFeature subPartFeature in part.Features!)
|
|
||||||
{
|
|
||||||
RemoveFields(subPartFeature);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="port">Port to remove fields from</param>
|
|
||||||
private void RemoveFields(Port port)
|
|
||||||
{
|
|
||||||
if (port.AnalogsSpecified)
|
|
||||||
{
|
|
||||||
foreach (Analog subAnalog in port.Analogs!)
|
|
||||||
{
|
|
||||||
RemoveFields(subAnalog);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="rom">Rom to remove fields from</param>
|
|
||||||
private void RemoveFields(Rom rom)
|
|
||||||
{
|
|
||||||
if (rom.DataAreaSpecified)
|
|
||||||
RemoveFields(rom.DataArea!);
|
|
||||||
|
|
||||||
if (rom.PartSpecified)
|
|
||||||
RemoveFields(rom.Part! as DatItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove fields with given values
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="slot">Slot to remove fields from</param>
|
|
||||||
private void RemoveFields(Slot slot)
|
|
||||||
{
|
|
||||||
if (slot.SlotOptionsSpecified)
|
|
||||||
{
|
|
||||||
foreach (SlotOption subSlotOption in slot.SlotOptions!)
|
|
||||||
{
|
|
||||||
RemoveFields(subSlotOption);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,8 +4,11 @@ using System.Linq;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endif
|
#endif
|
||||||
using SabreTools.Core;
|
using SabreTools.Core;
|
||||||
|
using SabreTools.Core.Tools;
|
||||||
using SabreTools.DatFiles;
|
using SabreTools.DatFiles;
|
||||||
using SabreTools.DatItems;
|
using SabreTools.DatItems;
|
||||||
|
using SabreTools.DatItems.Formats;
|
||||||
|
using SabreTools.Filter;
|
||||||
using SabreTools.Logging;
|
using SabreTools.Logging;
|
||||||
|
|
||||||
namespace SabreTools.Filtering
|
namespace SabreTools.Filtering
|
||||||
@@ -18,14 +21,19 @@ namespace SabreTools.Filtering
|
|||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DatItemRemover to remove fields from DatHeaders
|
/// List of header fields to exclude from writing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DatHeaderRemover? DatHeaderRemover { get; set; }
|
public List<string> HeaderFieldNames { get; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DatItemRemover to remove fields from DatItems
|
/// List of machine fields to exclude from writing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DatItemRemover? DatItemRemover { get; set; }
|
public List<string> MachineFieldNames { get; } = [];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of fields to exclude from writing
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, List<string>> ItemFieldNames { get; } = [];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -52,43 +60,71 @@ namespace SabreTools.Filtering
|
|||||||
|
|
||||||
#region Population
|
#region Population
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Populate the exclusion objects using a field name
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="field">Field names</param>
|
||||||
|
public void PopulateExclusions(string field)
|
||||||
|
=> PopulateExclusionsFromList([field]);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Populate the exclusion objects using a set of field names
|
/// Populate the exclusion objects using a set of field names
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fields">List of field names</param>
|
/// <param name="fields">List of field names</param>
|
||||||
public void PopulateExclusionsFromList(List<string>? fields)
|
public void PopulateExclusionsFromList(List<string>? fields)
|
||||||
{
|
{
|
||||||
// Instantiate the removers, if necessary
|
|
||||||
DatHeaderRemover ??= new DatHeaderRemover();
|
|
||||||
DatItemRemover ??= new DatItemRemover();
|
|
||||||
|
|
||||||
// If the list is null or empty, just return
|
// If the list is null or empty, just return
|
||||||
if (fields == null || fields.Count == 0)
|
if (fields == null || fields.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
InternalStopwatch watch = new("Populating removals from list");
|
var watch = new InternalStopwatch("Populating removals from list");
|
||||||
|
|
||||||
foreach (string field in fields)
|
foreach (string field in fields)
|
||||||
{
|
{
|
||||||
// If we don't even have a possible field name
|
bool removerSet = SetRemover(field);
|
||||||
if (field == null)
|
if (!removerSet)
|
||||||
continue;
|
logger.Warning($"The value {field} did not match any known field names. Please check the wiki for more details on supported field names.");
|
||||||
|
|
||||||
// DatHeader fields
|
|
||||||
if (DatHeaderRemover.SetRemover(field))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Machine and DatItem fields
|
|
||||||
if (DatItemRemover.SetRemover(field))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// If we didn't match anything, log an error
|
|
||||||
logger.Warning($"The value {field} did not match any known field names. Please check the wiki for more details on supported field names.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set remover from a value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="field">Key for the remover to be set</param>
|
||||||
|
private bool SetRemover(string field)
|
||||||
|
{
|
||||||
|
// If the key is null or empty, return false
|
||||||
|
if (string.IsNullOrEmpty(field))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Get the parser pair out of it, if possible
|
||||||
|
(string? key, string? value) = FilterParser.ParseFilterId(field);
|
||||||
|
if (key != null && value != null)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case Models.Metadata.MetadataFile.HeaderKey:
|
||||||
|
HeaderFieldNames.Add(value);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case Models.Metadata.MetadataFile.MachineKey:
|
||||||
|
MachineFieldNames.Add(value);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (!ItemFieldNames.ContainsKey(key))
|
||||||
|
ItemFieldNames[key] = [];
|
||||||
|
|
||||||
|
ItemFieldNames[key].Add(value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Running
|
#region Running
|
||||||
@@ -99,18 +135,14 @@ namespace SabreTools.Filtering
|
|||||||
/// <param name="datFile">Current DatFile object to run operations on</param>
|
/// <param name="datFile">Current DatFile object to run operations on</param>
|
||||||
public void ApplyRemovals(DatFile datFile)
|
public void ApplyRemovals(DatFile datFile)
|
||||||
{
|
{
|
||||||
// If the removers don't exist, we can't use it
|
|
||||||
if (DatHeaderRemover == null && DatItemRemover == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
InternalStopwatch watch = new("Applying removals to DAT");
|
InternalStopwatch watch = new("Applying removals to DAT");
|
||||||
|
|
||||||
// Remove DatHeader fields
|
// Remove DatHeader fields
|
||||||
if (DatHeaderRemover != null && DatHeaderRemover.DatHeaderFields.Any())
|
if (HeaderFieldNames.Any())
|
||||||
DatHeaderRemover.RemoveFields(datFile.Header);
|
RemoveFields(datFile.Header);
|
||||||
|
|
||||||
// Remove DatItem and Machine fields
|
// Remove DatItem and Machine fields
|
||||||
if (DatItemRemover != null && (DatItemRemover.MachineFields.Any() || DatItemRemover.DatItemFields.Any()))
|
if (MachineFieldNames.Any() || ItemFieldNames.Any())
|
||||||
{
|
{
|
||||||
#if NET452_OR_GREATER || NETCOREAPP
|
#if NET452_OR_GREATER || NETCOREAPP
|
||||||
Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key =>
|
Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key =>
|
||||||
@@ -130,7 +162,7 @@ namespace SabreTools.Filtering
|
|||||||
|
|
||||||
for (int j = 0; j < items.Count; j++)
|
for (int j = 0; j < items.Count; j++)
|
||||||
{
|
{
|
||||||
DatItemRemover.RemoveFields(items[j]);
|
RemoveFields(items[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
datFile.Items.Remove(key);
|
datFile.Items.Remove(key);
|
||||||
@@ -145,6 +177,330 @@ namespace SabreTools.Filtering
|
|||||||
watch.Stop();
|
watch.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="datItem">DatHeader to remove fields from</param>
|
||||||
|
public void RemoveFields(DatHeader datHeader)
|
||||||
|
{
|
||||||
|
if (datHeader == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// If there are no field names, return
|
||||||
|
if (HeaderFieldNames == null || !HeaderFieldNames.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var fieldName in HeaderFieldNames)
|
||||||
|
{
|
||||||
|
// TODO: Impelement in DatHeader
|
||||||
|
//datHeader.RemoveField(fieldName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="machine">Machine to remove fields from</param>
|
||||||
|
public void RemoveFields(Machine? machine)
|
||||||
|
{
|
||||||
|
if (machine == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// If there are no field names, return
|
||||||
|
if (MachineFieldNames == null || !MachineFieldNames.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var fieldName in MachineFieldNames)
|
||||||
|
{
|
||||||
|
machine.RemoveField(fieldName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="datItem">DatItem to remove fields from</param>
|
||||||
|
public void RemoveFields(DatItem? datItem)
|
||||||
|
{
|
||||||
|
if (datItem == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#region Common
|
||||||
|
|
||||||
|
// Handle Machine fields
|
||||||
|
if (MachineFieldNames != null && MachineFieldNames.Any() && datItem.Machine != null)
|
||||||
|
RemoveFields(datItem.Machine);
|
||||||
|
|
||||||
|
// If there are no field names, return
|
||||||
|
if (ItemFieldNames == null || !ItemFieldNames.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// If there are no field names for this type or generic, return
|
||||||
|
string? itemType = datItem.ItemType.AsStringValue<ItemType>();
|
||||||
|
if (itemType == null || (!ItemFieldNames.ContainsKey(itemType) && !ItemFieldNames.ContainsKey("item")))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Get the combined list of fields to remove
|
||||||
|
var fieldNames = new List<string>();
|
||||||
|
if (ItemFieldNames.ContainsKey(itemType))
|
||||||
|
fieldNames.AddRange(ItemFieldNames[itemType]);
|
||||||
|
if (ItemFieldNames.ContainsKey("item"))
|
||||||
|
fieldNames.AddRange(ItemFieldNames["item"]);
|
||||||
|
fieldNames = fieldNames.Distinct().ToList();
|
||||||
|
|
||||||
|
// If the field specifically contains Name, set it separately
|
||||||
|
if (fieldNames.Contains(Models.Metadata.Rom.NameKey))
|
||||||
|
datItem.SetName(null);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Item-Specific
|
||||||
|
|
||||||
|
// Handle unnested removals first
|
||||||
|
foreach (var datItemField in fieldNames)
|
||||||
|
{
|
||||||
|
datItem.RemoveField(datItemField);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle nested removals
|
||||||
|
switch (datItem)
|
||||||
|
{
|
||||||
|
case Adjuster adjuster: RemoveFields(adjuster); break;
|
||||||
|
case Configuration configuration: RemoveFields(configuration); break;
|
||||||
|
case ConfSetting confSetting: RemoveFields(confSetting); break;
|
||||||
|
case Device device: RemoveFields(device); break;
|
||||||
|
case DipSwitch dipSwitch: RemoveFields(dipSwitch); break;
|
||||||
|
case DipValue dipValue: RemoveFields(dipValue); break;
|
||||||
|
case Disk disk: RemoveFields(disk); break;
|
||||||
|
case Input input: RemoveFields(input); break;
|
||||||
|
case Part part: RemoveFields(part); break;
|
||||||
|
case Port port: RemoveFields(port); break;
|
||||||
|
case Rom rom: RemoveFields(rom); break;
|
||||||
|
case Slot slot: RemoveFields(slot); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="adjuster">Adjuster to remove fields from</param>
|
||||||
|
private void RemoveFields(Adjuster adjuster)
|
||||||
|
{
|
||||||
|
if (!adjuster.ConditionsSpecified)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (Condition subCondition in adjuster.Conditions!)
|
||||||
|
{
|
||||||
|
RemoveFields(subCondition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configuration">Configuration to remove fields from</param>
|
||||||
|
private void RemoveFields(Configuration configuration)
|
||||||
|
{
|
||||||
|
if (configuration.ConditionsSpecified)
|
||||||
|
{
|
||||||
|
foreach (Condition subCondition in configuration.Conditions!)
|
||||||
|
{
|
||||||
|
RemoveFields(subCondition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configuration.LocationsSpecified)
|
||||||
|
{
|
||||||
|
foreach (ConfLocation subLocation in configuration.Locations!)
|
||||||
|
{
|
||||||
|
RemoveFields(subLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configuration.SettingsSpecified)
|
||||||
|
{
|
||||||
|
foreach (ConfSetting subSetting in configuration.Settings!)
|
||||||
|
{
|
||||||
|
RemoveFields(subSetting as DatItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="confsetting">ConfSetting to remove fields from</param>
|
||||||
|
private void RemoveFields(ConfSetting confsetting)
|
||||||
|
{
|
||||||
|
if (confsetting.ConditionsSpecified)
|
||||||
|
{
|
||||||
|
foreach (Condition subCondition in confsetting.Conditions!)
|
||||||
|
{
|
||||||
|
RemoveFields(subCondition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="device">Device to remove fields from</param>
|
||||||
|
private void RemoveFields(Device device)
|
||||||
|
{
|
||||||
|
if (device.ExtensionsSpecified)
|
||||||
|
{
|
||||||
|
foreach (Extension subExtension in device.Extensions!)
|
||||||
|
{
|
||||||
|
RemoveFields(subExtension);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device.InstancesSpecified)
|
||||||
|
{
|
||||||
|
foreach (Instance subInstance in device.Instances!)
|
||||||
|
{
|
||||||
|
RemoveFields(subInstance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dipSwitch">DipSwitch to remove fields from</param>
|
||||||
|
private void RemoveFields(DipSwitch dipSwitch)
|
||||||
|
{
|
||||||
|
if (dipSwitch.ConditionsSpecified)
|
||||||
|
{
|
||||||
|
foreach (Condition subCondition in dipSwitch.Conditions!)
|
||||||
|
{
|
||||||
|
RemoveFields(subCondition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dipSwitch.LocationsSpecified)
|
||||||
|
{
|
||||||
|
foreach (DipLocation subLocation in dipSwitch.Locations!)
|
||||||
|
{
|
||||||
|
RemoveFields(subLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dipSwitch.ValuesSpecified)
|
||||||
|
{
|
||||||
|
foreach (DipValue subValue in dipSwitch.Values!)
|
||||||
|
{
|
||||||
|
RemoveFields(subValue as DatItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dipSwitch.PartSpecified)
|
||||||
|
RemoveFields(dipSwitch.Part! as DatItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dipValue">DipValue to remove fields from</param>
|
||||||
|
private void RemoveFields(DipValue dipValue)
|
||||||
|
{
|
||||||
|
if (dipValue.ConditionsSpecified)
|
||||||
|
{
|
||||||
|
foreach (Condition subCondition in dipValue.Conditions!)
|
||||||
|
{
|
||||||
|
RemoveFields(subCondition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disk">Disk to remove fields from</param>
|
||||||
|
private void RemoveFields(Disk disk)
|
||||||
|
{
|
||||||
|
if (disk.DiskAreaSpecified)
|
||||||
|
RemoveFields(disk.DiskArea);
|
||||||
|
|
||||||
|
if (disk.PartSpecified)
|
||||||
|
RemoveFields(disk.Part! as DatItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">Input to remove fields from</param>
|
||||||
|
private void RemoveFields(Input input)
|
||||||
|
{
|
||||||
|
if (input.ControlsSpecified)
|
||||||
|
{
|
||||||
|
foreach (Control subControl in input.Controls!)
|
||||||
|
{
|
||||||
|
RemoveFields(subControl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="part">Part to remove fields from</param>
|
||||||
|
private void RemoveFields(Part part)
|
||||||
|
{
|
||||||
|
if (part.FeaturesSpecified)
|
||||||
|
{
|
||||||
|
foreach (PartFeature subPartFeature in part.Features!)
|
||||||
|
{
|
||||||
|
RemoveFields(subPartFeature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="port">Port to remove fields from</param>
|
||||||
|
private void RemoveFields(Port port)
|
||||||
|
{
|
||||||
|
if (port.AnalogsSpecified)
|
||||||
|
{
|
||||||
|
foreach (Analog subAnalog in port.Analogs!)
|
||||||
|
{
|
||||||
|
RemoveFields(subAnalog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rom">Rom to remove fields from</param>
|
||||||
|
private void RemoveFields(Rom rom)
|
||||||
|
{
|
||||||
|
if (rom.DataAreaSpecified)
|
||||||
|
RemoveFields(rom.DataArea!);
|
||||||
|
|
||||||
|
if (rom.PartSpecified)
|
||||||
|
RemoveFields(rom.Part! as DatItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove fields with given values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="slot">Slot to remove fields from</param>
|
||||||
|
private void RemoveFields(Slot slot)
|
||||||
|
{
|
||||||
|
if (slot.SlotOptionsSpecified)
|
||||||
|
{
|
||||||
|
foreach (SlotOption subSlotOption in slot.SlotOptions!)
|
||||||
|
{
|
||||||
|
RemoveFields(subSlotOption);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using SabreTools.Filtering;
|
using SabreTools.Filtering;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@@ -18,29 +17,25 @@ namespace SabreTools.Test.Filtering
|
|||||||
remover.PopulateExclusionsFromList(exclusions);
|
remover.PopulateExclusionsFromList(exclusions);
|
||||||
|
|
||||||
// Check the exclusion lists
|
// Check the exclusion lists
|
||||||
Assert.NotNull(remover.DatHeaderRemover);
|
Assert.Empty(remover.HeaderFieldNames);
|
||||||
Assert.NotNull(remover.DatItemRemover);
|
Assert.Empty(remover.MachineFieldNames);
|
||||||
Assert.Empty(remover.DatHeaderRemover.DatHeaderFields);
|
Assert.Empty(remover.ItemFieldNames);
|
||||||
Assert.Empty(remover.DatItemRemover.MachineFields);
|
|
||||||
Assert.Empty(remover.DatItemRemover.DatItemFields);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void PopulateExclusionEmptyListTest()
|
public void PopulateExclusionEmptyListTest()
|
||||||
{
|
{
|
||||||
// Setup the list
|
// Setup the list
|
||||||
List<string> exclusions = new();
|
List<string> exclusions = [];
|
||||||
|
|
||||||
// Setup the remover
|
// Setup the remover
|
||||||
var remover = new Remover();
|
var remover = new Remover();
|
||||||
remover.PopulateExclusionsFromList(exclusions);
|
remover.PopulateExclusionsFromList(exclusions);
|
||||||
|
|
||||||
// Check the exclusion lists
|
// Check the exclusion lists
|
||||||
Assert.NotNull(remover.DatHeaderRemover);
|
Assert.Empty(remover.HeaderFieldNames);
|
||||||
Assert.NotNull(remover.DatItemRemover);
|
Assert.Empty(remover.MachineFieldNames);
|
||||||
Assert.Empty(remover.DatHeaderRemover.DatHeaderFields);
|
Assert.Empty(remover.ItemFieldNames);
|
||||||
Assert.Empty(remover.DatItemRemover.MachineFields);
|
|
||||||
Assert.Empty(remover.DatItemRemover.DatItemFields);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -57,11 +52,9 @@ namespace SabreTools.Test.Filtering
|
|||||||
remover.PopulateExclusionsFromList(exclusions);
|
remover.PopulateExclusionsFromList(exclusions);
|
||||||
|
|
||||||
// Check the exclusion lists
|
// Check the exclusion lists
|
||||||
Assert.NotNull(remover.DatHeaderRemover);
|
Assert.Empty(remover.HeaderFieldNames);
|
||||||
Assert.NotNull(remover.DatItemRemover);
|
Assert.Empty(remover.MachineFieldNames);
|
||||||
Assert.Single(remover.DatHeaderRemover.DatHeaderFields);
|
Assert.Empty(remover.ItemFieldNames);
|
||||||
Assert.Empty(remover.DatItemRemover.MachineFields);
|
|
||||||
Assert.Empty(remover.DatItemRemover.DatItemFields);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -78,11 +71,9 @@ namespace SabreTools.Test.Filtering
|
|||||||
remover.PopulateExclusionsFromList(exclusions);
|
remover.PopulateExclusionsFromList(exclusions);
|
||||||
|
|
||||||
// Check the exclusion lists
|
// Check the exclusion lists
|
||||||
Assert.NotNull(remover.DatHeaderRemover);
|
Assert.Empty(remover.HeaderFieldNames);
|
||||||
Assert.NotNull(remover.DatItemRemover);
|
Assert.Single(remover.MachineFieldNames);
|
||||||
Assert.Empty(remover.DatHeaderRemover.DatHeaderFields);
|
Assert.Empty(remover.ItemFieldNames);
|
||||||
Assert.Single(remover.DatItemRemover.MachineFields);
|
|
||||||
Assert.Empty(remover.DatItemRemover.DatItemFields);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@@ -99,11 +90,9 @@ namespace SabreTools.Test.Filtering
|
|||||||
remover.PopulateExclusionsFromList(exclusions);
|
remover.PopulateExclusionsFromList(exclusions);
|
||||||
|
|
||||||
// Check the exclusion lists
|
// Check the exclusion lists
|
||||||
Assert.NotNull(remover.DatHeaderRemover);
|
Assert.Empty(remover.HeaderFieldNames);
|
||||||
Assert.NotNull(remover.DatItemRemover);
|
Assert.Empty(remover.MachineFieldNames);
|
||||||
Assert.Empty(remover.DatHeaderRemover.DatHeaderFields);
|
Assert.Single(remover.ItemFieldNames);
|
||||||
Assert.Empty(remover.DatItemRemover.MachineFields);
|
|
||||||
Assert.Single(remover.DatItemRemover.DatItemFields);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ namespace SabreTools.Test.Filtering
|
|||||||
public void RemoveFieldsDatItemTest()
|
public void RemoveFieldsDatItemTest()
|
||||||
{
|
{
|
||||||
var datItem = CreateDatItem();
|
var datItem = CreateDatItem();
|
||||||
var remover = new DatItemRemover();
|
var remover = new Remover();
|
||||||
remover.SetRemover("DatItem.Name");
|
remover.PopulateExclusions("DatItem.Name");
|
||||||
remover.RemoveFields(datItem);
|
remover.RemoveFields(datItem);
|
||||||
Assert.Null(datItem.GetName());
|
Assert.Null(datItem.GetName());
|
||||||
}
|
}
|
||||||
@@ -21,8 +21,8 @@ namespace SabreTools.Test.Filtering
|
|||||||
public void RemoveFieldsMachineTest()
|
public void RemoveFieldsMachineTest()
|
||||||
{
|
{
|
||||||
var datItem = CreateDatItem();
|
var datItem = CreateDatItem();
|
||||||
var remover = new DatItemRemover();
|
var remover = new Remover();
|
||||||
remover.SetRemover("Machine.Name");
|
remover.PopulateExclusions("Machine.Name");
|
||||||
remover.RemoveFields(datItem);
|
remover.RemoveFields(datItem);
|
||||||
Assert.Null(datItem.Machine.Name);
|
Assert.Null(datItem.Machine.Name);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user