Scan single types, not assemblies.

This commit is contained in:
feyris-tan 2026-01-21 21:43:45 +01:00
parent 78bed400ee
commit 8e57233dad

View File

@ -42,13 +42,22 @@ namespace Voile.Patchouli.Reflection
Type[] types = assembly.GetTypes(); Type[] types = assembly.GetTypes();
foreach (Type t in types) foreach (Type t in types)
{ {
if (ScanType(t))
result = true;
}
return result;
}
public bool ScanType(Type t)
{
VoilePluginAttribute? voilePluginAttribute = t.GetCustomAttribute<VoilePluginAttribute>(); VoilePluginAttribute? voilePluginAttribute = t.GetCustomAttribute<VoilePluginAttribute>();
if (voilePluginAttribute == null) if (voilePluginAttribute == null)
continue; return false;
VoilePluginIdAttribute? voilePluginIdAttribute = t.GetCustomAttribute<VoilePluginIdAttribute>(); VoilePluginIdAttribute? voilePluginIdAttribute = t.GetCustomAttribute<VoilePluginIdAttribute>();
if (voilePluginIdAttribute == null) if (voilePluginIdAttribute == null)
continue; return false;
VoilePluginInfo child = new VoilePluginInfo(t); VoilePluginInfo child = new VoilePluginInfo(t);
child.Id = voilePluginIdAttribute.Id; child.Id = voilePluginIdAttribute.Id;
@ -59,8 +68,7 @@ namespace Voile.Patchouli.Reflection
_knownDataStorages = new List<VoilePluginInfo>(); _knownDataStorages = new List<VoilePluginInfo>();
child.Subsystem = VoileSubsystemType.DataStorage; child.Subsystem = VoileSubsystemType.DataStorage;
_knownDataStorages.Add(child); _knownDataStorages.Add(child);
result = true; return true;
continue;
} }
else if (t.IsAssignableTo(_objectStorageFactoryType)) else if (t.IsAssignableTo(_objectStorageFactoryType))
{ {
@ -68,15 +76,12 @@ namespace Voile.Patchouli.Reflection
_knownObjectStorages = new List<VoilePluginInfo>(); _knownObjectStorages = new List<VoilePluginInfo>();
child.Subsystem = VoileSubsystemType.ObjectStorage; child.Subsystem = VoileSubsystemType.ObjectStorage;
_knownObjectStorages.Add(child); _knownObjectStorages.Add(child);
result = true; return true;
continue;
} }
else else
{ {
throw new VoileReflectionException(String.Format("Could not figure out plugin type of {0}", t.Name));
} }
} }
return result;
}
} }
} }