GetProperties is only used by filters

This commit is contained in:
Matt Nadareski
2026-04-05 11:24:47 -04:00
parent 15794e07f7
commit d78c1eb9ed
2 changed files with 20 additions and 19 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Reflection;
using SabreTools.Data.Models.Metadata;
namespace SabreTools.Metadata.Filter
@@ -111,7 +112,7 @@ namespace SabreTools.Metadata.Filter
private static bool ParseHeaderFilterId(ref string itemName, ref string fieldName)
{
// Get the set of properties
var properties = TypeHelper.GetProperties(typeof(Header));
var properties = GetProperties(typeof(Header));
if (properties is null)
return false;
@@ -133,7 +134,7 @@ namespace SabreTools.Metadata.Filter
private static bool ParseMachineFilterId(ref string itemName, ref string fieldName)
{
// Get the set of properties
var properties = TypeHelper.GetProperties(typeof(Machine));
var properties = GetProperties(typeof(Machine));
if (properties is null)
return false;
@@ -206,7 +207,7 @@ namespace SabreTools.Metadata.Filter
return null;
// Get the set of properties
var properties = TypeHelper.GetProperties(itemType);
var properties = GetProperties(itemType);
if (properties is null)
return null;
@@ -214,5 +215,21 @@ namespace SabreTools.Metadata.Filter
string? propertyMatch = Array.Find(properties, c => string.Equals(c, fieldName, StringComparison.OrdinalIgnoreCase));
return propertyMatch?.ToLowerInvariant();
}
/// <summary>
/// Get property names for the given type, if possible
/// </summary>
private static string[]? GetProperties(Type? type)
{
if (type is null)
return null;
var properties = type.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public);
if (properties is null)
return null;
string[] propertyNames = Array.ConvertAll(properties, f => f.Name);
return Array.FindAll(propertyNames, s => s.Length > 0);
}
}
}

View File

@@ -55,22 +55,6 @@ namespace SabreTools.Metadata
return null;
}
/// <summary>
/// Get property names for the given type, if possible
/// </summary>
public static string[]? GetProperties(Type? type)
{
if (type is null)
return null;
var properties = type.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public);
if (properties is null)
return null;
string[] propertyNames = Array.ConvertAll(properties, f => f.Name);
return Array.FindAll(propertyNames, s => s.Length > 0);
}
/// <summary>
/// Attempt to get the XmlRootAttribute.ElementName value from a type
/// </summary>