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,41 +42,46 @@ namespace Voile.Patchouli.Reflection
Type[] types = assembly.GetTypes();
foreach (Type t in types)
{
VoilePluginAttribute? voilePluginAttribute = t.GetCustomAttribute<VoilePluginAttribute>();
if (voilePluginAttribute == null)
continue;
VoilePluginIdAttribute? voilePluginIdAttribute = t.GetCustomAttribute<VoilePluginIdAttribute>();
if (voilePluginIdAttribute == null)
continue;
VoilePluginInfo child = new VoilePluginInfo(t);
child.Id = voilePluginIdAttribute.Id;
if (t.IsAssignableTo(_dataStorageFactoryType))
{
if (_knownDataStorages == null)
_knownDataStorages = new List<VoilePluginInfo>();
child.Subsystem = VoileSubsystemType.DataStorage;
_knownDataStorages.Add(child);
if (ScanType(t))
result = true;
continue;
}
else if (t.IsAssignableTo(_objectStorageFactoryType))
{
if (_knownObjectStorages == null)
_knownObjectStorages = new List<VoilePluginInfo>();
child.Subsystem = VoileSubsystemType.ObjectStorage;
_knownObjectStorages.Add(child);
result = true;
continue;
}
else
{
}
}
return result;
}
public bool ScanType(Type t)
{
VoilePluginAttribute? voilePluginAttribute = t.GetCustomAttribute<VoilePluginAttribute>();
if (voilePluginAttribute == null)
return false;
VoilePluginIdAttribute? voilePluginIdAttribute = t.GetCustomAttribute<VoilePluginIdAttribute>();
if (voilePluginIdAttribute == null)
return false;
VoilePluginInfo child = new VoilePluginInfo(t);
child.Id = voilePluginIdAttribute.Id;
if (t.IsAssignableTo(_dataStorageFactoryType))
{
if (_knownDataStorages == null)
_knownDataStorages = new List<VoilePluginInfo>();
child.Subsystem = VoileSubsystemType.DataStorage;
_knownDataStorages.Add(child);
return true;
}
else if (t.IsAssignableTo(_objectStorageFactoryType))
{
if (_knownObjectStorages == null)
_knownObjectStorages = new List<VoilePluginInfo>();
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));
}
}
}
}