mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-08 18:06:41 +00:00
GetProperties is only used by filters
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user