2022-09-22 08:56:07 +08:00
|
|
|
|
using dnlib.DotNet;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace HybridCLR.Editor.Meta
|
|
|
|
|
{
|
2023-11-23 13:48:06 +08:00
|
|
|
|
public class AssemblyReferenceDeepCollector : AssemblyCacheBase
|
2022-09-22 08:56:07 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly List<string> _rootAssemblies;
|
|
|
|
|
|
|
|
|
|
public IReadOnlyList<string> GetRootAssemblyNames()
|
|
|
|
|
{
|
|
|
|
|
return _rootAssemblies;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ModuleDefMD> GetLoadedModulesExcludeRootAssemblies()
|
|
|
|
|
{
|
|
|
|
|
return LoadedModules.Where(e => !_rootAssemblies.Contains(e.Key)).Select(e => e.Value).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-07 21:59:56 +08:00
|
|
|
|
public List<ModuleDefMD> GetLoadedModules()
|
|
|
|
|
{
|
|
|
|
|
return LoadedModules.Select(e => e.Value).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 08:56:07 +08:00
|
|
|
|
public List<ModuleDefMD> GetLoadedModulesOfRootAssemblies()
|
|
|
|
|
{
|
|
|
|
|
return _rootAssemblies.Select(ass => LoadedModules[ass]).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-23 13:48:06 +08:00
|
|
|
|
public AssemblyReferenceDeepCollector(IAssemblyResolver assemblyResolver, List<string> rootAssemblies) : base(assemblyResolver)
|
2022-09-22 08:56:07 +08:00
|
|
|
|
{
|
|
|
|
|
_rootAssemblies = rootAssemblies;
|
|
|
|
|
LoadAllAssembiles();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadAllAssembiles()
|
|
|
|
|
{
|
|
|
|
|
foreach (var asm in _rootAssemblies)
|
|
|
|
|
{
|
|
|
|
|
LoadModule(asm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|