mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Make FilterRunner more accurate
This commit is contained in:
@@ -45,14 +45,13 @@ namespace SabreTools.Filter
|
|||||||
{
|
{
|
||||||
Header => MetadataFile.HeaderKey,
|
Header => MetadataFile.HeaderKey,
|
||||||
Machine => MetadataFile.MachineKey,
|
Machine => MetadataFile.MachineKey,
|
||||||
DatItem => dictionaryBase.ReadString(DatItem.TypeKey),
|
DatItem => TypeHelper.GetXmlRootAttributeElementName(dictionaryBase.GetType()),
|
||||||
_ => null,
|
_ => null,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Loop through and run each filter in order
|
// Loop through and run each filter in order
|
||||||
foreach (var filter in this.Filters)
|
foreach (var filter in this.Filters)
|
||||||
{
|
{
|
||||||
// TODO: Make this step more accurate
|
|
||||||
// If the filter isn't for this object type, skip
|
// If the filter isn't for this object type, skip
|
||||||
if (filter.Key[0] != itemName)
|
if (filter.Key[0] != itemName)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -40,7 +40,18 @@ namespace SabreTools.Filter
|
|||||||
return AppDomain.CurrentDomain.GetAssemblies()
|
return AppDomain.CurrentDomain.GetAssemblies()
|
||||||
.SelectMany(a => a.GetTypes())
|
.SelectMany(a => a.GetTypes())
|
||||||
.Where(t => t.IsAssignableFrom(typeof(DatItem)) && t.IsClass)
|
.Where(t => t.IsAssignableFrom(typeof(DatItem)) && t.IsClass)
|
||||||
.FirstOrDefault(t => t.GetCustomAttribute<XmlRootAttribute>()?.ElementName == itemType);
|
.FirstOrDefault(t => GetXmlRootAttributeElementName(t) == itemType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempt to get the XmlRootAttribute.ElementName value from a type
|
||||||
|
/// </summary>
|
||||||
|
public static string? GetXmlRootAttributeElementName(Type? type)
|
||||||
|
{
|
||||||
|
if (type == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return type.GetCustomAttribute<XmlRootAttribute>()?.ElementName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ namespace SabreTools.Models.Internal
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determine what type of file an item is
|
/// Determine what type of file an item is
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>TODO: Create attribute for internal names</remarks>
|
|
||||||
public enum ItemType
|
public enum ItemType
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user