Options.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Jint
  4. {
  5. public class Options
  6. {
  7. private bool _discardGlobal;
  8. private bool _strict;
  9. private readonly Dictionary<string, Delegate> _delegates = new Dictionary<string, Delegate>();
  10. /// <summary>
  11. /// When called, doesn't initialize the global scope.
  12. /// Can be useful in lightweight scripts for performance reason.
  13. /// </summary>
  14. public Options DiscardGlobal(bool discard = true)
  15. {
  16. _discardGlobal = discard;
  17. return this;
  18. }
  19. public Options Strict(bool strict = true)
  20. {
  21. _strict = strict;
  22. return this;
  23. }
  24. public Options WithDelegate(string name, Delegate del)
  25. {
  26. _delegates[name] = del;
  27. return this;
  28. }
  29. internal bool GetDiscardGlobal()
  30. {
  31. return _discardGlobal;
  32. }
  33. internal IDictionary<string, Delegate> GetDelegates()
  34. {
  35. return _delegates;
  36. }
  37. internal bool IsStrict()
  38. {
  39. return _strict;
  40. }
  41. }
  42. }