Lookup resource storage type safely
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user