浏览代码

Secure check for assembly types in Manager.cs

/main
peeweek 5 年前
当前提交
67dfc46a
共有 1 个文件被更改,包括 19 次插入4 次删除
  1. 23
      Runtime/Managers/Manager.cs

23
Runtime/Managers/Manager.cs


List<Type> types = new List<Type>();
foreach(var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
foreach(Type t in assembly.GetTypes())
Type[] assemblyTypes = null;
try
{
assemblyTypes = assembly.GetTypes();
}
catch
{
Debug.LogError($"Could not load types from assembly : {assembly.FullName}");
}
if(assemblyTypes != null)
if(typeof(Manager).IsAssignableFrom(t) && !t.IsAbstract)
foreach (Type t in assemblyTypes)
types.Add(t);
}
if (typeof(Manager).IsAssignableFrom(t) && !t.IsAbstract)
{
types.Add(t);
}
}
}
return types.ToArray();
}
正在加载...
取消
保存