hybridclr_unity/Editor/Meta/AssemblyReferenceDeepCollec...

51 lines
1.4 KiB
C#
Raw Permalink Normal View History

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
{
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();
}
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();
}
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);
}
}
}
}