Lookup resource storage type safely

This commit is contained in:
2025-12-14 13:12:08 +01:00
parent b05c3415f2
commit 1035f06884

View File

@@ -12,15 +12,24 @@ namespace KCM
private static MethodInfo isPrivateMethod; private static MethodInfo isPrivateMethod;
private static MethodInfo addResourceStorageMethod; private static MethodInfo addResourceStorageMethod;
private static readonly string[] resourceStorageTypeNames = new[]
{
"Assets.Interface.IResourceStorage, Assembly-CSharp",
"Assets.Interface.IResourceStorage, Assembly-CSharp-firstpass",
"Assets.Interface.IResourceStorage, Assembly-CSharp-Editor",
};
private static void EnsureInitialized() private static void EnsureInitialized()
{ {
if (resourceStorageType != null) if (resourceStorageType != null)
return; return;
resourceStorageType = AppDomain.CurrentDomain foreach (var typeName in resourceStorageTypeNames)
.GetAssemblies() {
.Select(a => a.GetType("Assets.Interface.IResourceStorage", false)) resourceStorageType = Type.GetType(typeName);
.FirstOrDefault(t => t != null); if (resourceStorageType != null)
break;
}
if (resourceStorageType == null) if (resourceStorageType == null)
return; return;