IScriptLoader.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace MoonSharp.Interpreter.Loaders
  6. {
  7. /// <summary>
  8. /// Class dictating how requests to read scripts from files are handled.
  9. ///
  10. /// It's recommended that no class implement IScriptLoader directly, and rather extend ScriptLoaderBase.
  11. /// </summary>
  12. public interface IScriptLoader
  13. {
  14. /// <summary>
  15. /// Opens a file for reading the script code.
  16. /// It can return either a string, a byte[] or a Stream.
  17. /// If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's
  18. /// assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place.
  19. /// </summary>
  20. /// <param name="file">The file.</param>
  21. /// <param name="globalContext">The global context.</param>
  22. /// <returns>
  23. /// A string, a byte[] or a Stream.
  24. /// </returns>
  25. object LoadFile(string file, Table globalContext);
  26. /// <summary>
  27. /// Resolves a filename [applying paths, etc.]
  28. /// </summary>
  29. /// <param name="filename">The filename.</param>
  30. /// <param name="globalContext">The global context.</param>
  31. /// <returns></returns>
  32. [Obsolete("This serves almost no purpose. Kept here just to preserve backward compatibility.")]
  33. string ResolveFileName(string filename, Table globalContext);
  34. /// <summary>
  35. /// Resolves the name of a module to a filename (which will later be passed to OpenScriptFile)
  36. /// </summary>
  37. /// <param name="modname">The modname.</param>
  38. /// <param name="globalContext">The global context.</param>
  39. /// <returns></returns>
  40. string ResolveModuleName(string modname, Table globalContext);
  41. }
  42. }