CSharpAssetReferencesManifest.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. namespace XGame.Framework.Asset
  4. {
  5. public class CSharpAssetReferencesManifest : IAssetReferencesManifest, IDisposable
  6. {
  7. /// <summary>
  8. /// key:assetPath
  9. /// value:references
  10. /// </summary>
  11. private Dictionary<string, string[]> _referencesMap;
  12. public CSharpAssetReferencesManifest(AssetReferenceInfosSo manifest)
  13. {
  14. _referencesMap = new Dictionary<string, string[]>();
  15. Init(manifest);
  16. }
  17. private void Init(AssetReferenceInfosSo manifest)
  18. {
  19. if (manifest == null || manifest.references == null)
  20. return;
  21. foreach(var reference in manifest.references)
  22. {
  23. _referencesMap.Add(reference.assetName, reference.references);
  24. }
  25. }
  26. public string[] GetReferencesByAssetName(string assetName)
  27. {
  28. _referencesMap.TryGetValue(assetName, out var result);
  29. return result;
  30. }
  31. void IDisposable.Dispose()
  32. {
  33. _referencesMap.Clear();
  34. }
  35. }
  36. }