FixedSetAssemblyResolver.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using UnityEngine;
  8. namespace HybridCLR.Editor.Meta
  9. {
  10. public class FixedSetAssemblyResolver : AssemblyResolverBase
  11. {
  12. private readonly string _rootDir;
  13. private readonly HashSet<string> _fileNames;
  14. public FixedSetAssemblyResolver(string rootDir, IEnumerable<string> fileNameNotExts)
  15. {
  16. _rootDir = rootDir;
  17. _fileNames = new HashSet<string>(fileNameNotExts);
  18. }
  19. protected override bool TryResolveAssembly(string assemblyName, out string assemblyPath)
  20. {
  21. if (_fileNames.Contains(assemblyName))
  22. {
  23. assemblyPath = $"{_rootDir}/{assemblyName}.dll";
  24. if (File.Exists(assemblyPath))
  25. {
  26. Debug.Log($"[FixedSetAssemblyResolver] resolve:{assemblyName} path:{assemblyPath}");
  27. return true;
  28. }
  29. }
  30. assemblyPath = null;
  31. return false;
  32. }
  33. }
  34. }