mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-08 18:06:41 +00:00
None of these are constants now
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user