From 8e57233dad3d28745a813244be752eecad503d7c Mon Sep 17 00:00:00 2001 From: feyris-tan <4116042+feyris-tan@users.noreply.github.com> Date: Wed, 21 Jan 2026 21:43:45 +0100 Subject: [PATCH] Scan single types, not assemblies. --- .../Reflection/VoilePluginManager.cs | 69 ++++++++++--------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/Voile.Patchouli/Reflection/VoilePluginManager.cs b/Voile.Patchouli/Reflection/VoilePluginManager.cs index 7fcc913..0a3522b 100644 --- a/Voile.Patchouli/Reflection/VoilePluginManager.cs +++ b/Voile.Patchouli/Reflection/VoilePluginManager.cs @@ -42,41 +42,46 @@ namespace Voile.Patchouli.Reflection Type[] types = assembly.GetTypes(); foreach (Type t in types) { - VoilePluginAttribute? voilePluginAttribute = t.GetCustomAttribute(); - if (voilePluginAttribute == null) - continue; - - VoilePluginIdAttribute? voilePluginIdAttribute = t.GetCustomAttribute(); - if (voilePluginIdAttribute == null) - continue; - - VoilePluginInfo child = new VoilePluginInfo(t); - child.Id = voilePluginIdAttribute.Id; - - if (t.IsAssignableTo(_dataStorageFactoryType)) - { - if (_knownDataStorages == null) - _knownDataStorages = new List(); - child.Subsystem = VoileSubsystemType.DataStorage; - _knownDataStorages.Add(child); + if (ScanType(t)) result = true; - continue; - } - else if (t.IsAssignableTo(_objectStorageFactoryType)) - { - if (_knownObjectStorages == null) - _knownObjectStorages = new List(); - child.Subsystem = VoileSubsystemType.ObjectStorage; - _knownObjectStorages.Add(child); - result = true; - continue; - } - else - { - - } } return result; } + + public bool ScanType(Type t) + { + + VoilePluginAttribute? voilePluginAttribute = t.GetCustomAttribute(); + if (voilePluginAttribute == null) + return false; + + VoilePluginIdAttribute? voilePluginIdAttribute = t.GetCustomAttribute(); + if (voilePluginIdAttribute == null) + return false; + + VoilePluginInfo child = new VoilePluginInfo(t); + child.Id = voilePluginIdAttribute.Id; + + if (t.IsAssignableTo(_dataStorageFactoryType)) + { + if (_knownDataStorages == null) + _knownDataStorages = new List(); + child.Subsystem = VoileSubsystemType.DataStorage; + _knownDataStorages.Add(child); + return true; + } + else if (t.IsAssignableTo(_objectStorageFactoryType)) + { + if (_knownObjectStorages == null) + _knownObjectStorages = new List(); + child.Subsystem = VoileSubsystemType.ObjectStorage; + _knownObjectStorages.Add(child); + return true; + } + else + { + throw new VoileReflectionException(String.Format("Could not figure out plugin type of {0}", t.Name)); + } + } } }