None of these are constants now

This commit is contained in:
Matt Nadareski
2026-04-05 00:25:56 -04:00
parent 72dac4d6e2
commit 2969324015
2 changed files with 0 additions and 67 deletions

View File

@@ -101,22 +101,6 @@ namespace SabreTools.Metadata.Filter
/// </summary>
private static bool ParseHeaderFilterId(ref string itemName, ref string fieldName)
{
// Get the set of constants
var constants = TypeHelper.GetConstants(typeof(Header));
if (constants is not null)
{
// Get if there's a match to a constant
string localFieldName = fieldName;
string? constantMatch = Array.Find(constants, c => string.Equals(c, localFieldName, StringComparison.OrdinalIgnoreCase));
if (constantMatch is not null)
{
// Return the sanitized ID
itemName = "header";
fieldName = constantMatch;
return true;
}
}
// Get the set of properties
var properties = TypeHelper.GetProperties(typeof(Header));
if (properties is not null)
@@ -141,22 +125,6 @@ namespace SabreTools.Metadata.Filter
/// </summary>
private static bool ParseMachineFilterId(ref string itemName, ref string fieldName)
{
// Get the set of constants
var constants = TypeHelper.GetConstants(typeof(Machine));
if (constants is not null)
{
// Get if there's a match to a constant
string localFieldName = fieldName;
string? constantMatch = Array.Find(constants, c => string.Equals(c, localFieldName, StringComparison.OrdinalIgnoreCase));
if (constantMatch is not null)
{
// Return the sanitized ID
itemName = "machine";
fieldName = constantMatch;
return true;
}
}
// Get the set of properties
var properties = TypeHelper.GetProperties(typeof(Machine));
if (properties is not null)
@@ -235,16 +203,6 @@ namespace SabreTools.Metadata.Filter
if (itemType is null)
return null;
// Get the set of constants
var constants = TypeHelper.GetConstants(itemType);
if (constants is not null)
{
// Get if there's a match to a constant
string? constantMatch = Array.Find(constants, c => string.Equals(c, fieldName, StringComparison.OrdinalIgnoreCase));
if (constantMatch is not null)
return constantMatch;
}
// Get the set of properties
var properties = TypeHelper.GetProperties(itemType);
if (properties is not null)

View File

@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using System.Xml.Serialization;
using SabreTools.Data.Models;
using SabreTools.Data.Models.Metadata;
namespace SabreTools.Metadata
@@ -10,30 +9,6 @@ namespace SabreTools.Metadata
// TODO: Investigate ways of either caching or speeding up these methods
public static class TypeHelper
{
/// <summary>
/// Get constant values for the given type, if possible
/// </summary>
/// <remarks>Does not return any values marked with the <see cref="NoFilterAttribute"/></remarks>
public static string[]? GetConstants(Type? type)
{
if (type is null)
return null;
var fields = type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
if (fields is null)
return null;
FieldInfo[] noFilterFields = Array.FindAll(fields,
f => f.IsLiteral
&& !f.IsInitOnly
&& Attribute.GetCustomAttributes(f, typeof(NoFilterAttribute)).Length == 0);
string[] constantValues = Array.ConvertAll(noFilterFields,
f => (f.GetRawConstantValue() as string) ?? string.Empty);
return Array.FindAll(constantValues, s => s.Length > 0);
}
/// <summary>
/// Attempt to get all DatItem types
/// </summary>