IAssetLoader.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using System.IO;
  5. using System.Reflection;
  6. namespace Avalonia.Platform
  7. {
  8. /// <summary>
  9. /// Loads assets compiled into the application binary.
  10. /// </summary>
  11. public interface IAssetLoader
  12. {
  13. /// <summary>
  14. /// We need a way to override the default assembly selected by the host platform
  15. /// because right now it is selecting the wrong one for PCL based Apps. The
  16. /// AssetLoader needs a refactor cause right now it lives in 3+ platforms which
  17. /// can all be loaded on Windows.
  18. /// </summary>
  19. /// <param name="asm"></param>
  20. void SetDefaultAssembly(Assembly asm);
  21. /// <summary>
  22. /// Checks if an asset with the specified URI exists.
  23. /// </summary>
  24. /// <param name="uri">The URI.</param>
  25. /// <param name="baseUri">
  26. /// A base URI to use if <paramref name="uri"/> is relative.
  27. /// </param>
  28. /// <returns>True if the asset could be found; otherwise false.</returns>
  29. bool Exists(Uri uri, Uri baseUri = null);
  30. /// <summary>
  31. /// Opens the resource with the requested URI.
  32. /// </summary>
  33. /// <param name="uri">The URI.</param>
  34. /// <param name="baseUri">
  35. /// A base URI to use if <paramref name="uri"/> is relative.
  36. /// </param>
  37. /// <returns>A stream containing the resource contents.</returns>
  38. /// <exception cref="FileNotFoundException">
  39. /// The resource was not found.
  40. /// </exception>
  41. Stream Open(Uri uri, Uri baseUri = null);
  42. /// <summary>
  43. /// Opens the resource with the requested URI and returns the resource string and the
  44. /// assembly containing the resource.
  45. /// </summary>
  46. /// <param name="uri">The URI.</param>
  47. /// <param name="baseUri">
  48. /// A base URI to use if <paramref name="uri"/> is relative.
  49. /// </param>
  50. /// <returns>
  51. /// The stream containing the resource contents together with the assembly.
  52. /// </returns>
  53. /// <exception cref="FileNotFoundException">
  54. /// The resource was not found.
  55. /// </exception>
  56. Tuple<Stream, Assembly> OpenAndGetAssembly(Uri uri, Uri baseUri = null);
  57. }
  58. }