Options.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. namespace Jint
  2. {
  3. public class Options
  4. {
  5. private bool _discardGlobal;
  6. private bool _strict;
  7. private bool _allowDebuggerStatement;
  8. /// <summary>
  9. /// When called, doesn't initialize the global scope.
  10. /// Can be useful in lightweight scripts for performance reason.
  11. /// </summary>
  12. public Options DiscardGlobal(bool discard = true)
  13. {
  14. _discardGlobal = discard;
  15. return this;
  16. }
  17. /// <summary>
  18. /// Run the script in strict mode.
  19. /// </summary>
  20. public Options Strict(bool strict = true)
  21. {
  22. _strict = strict;
  23. return this;
  24. }
  25. /// <summary>
  26. /// Allow the <code>debugger</code> statement to be called in a script.
  27. /// </summary>
  28. /// <remarks>
  29. /// Because the <code>debugger</code> statement can start the
  30. /// Visual Studio debugger, is it disabled by default
  31. /// </remarks>
  32. public Options AllowDebuggerStatement(bool allowDebuggerStatement = true)
  33. {
  34. _allowDebuggerStatement = allowDebuggerStatement;
  35. return this;
  36. }
  37. internal bool GetDiscardGlobal()
  38. {
  39. return _discardGlobal;
  40. }
  41. internal bool IsStrict()
  42. {
  43. return _strict;
  44. }
  45. internal bool IsDebuggerStatementAllowed()
  46. {
  47. return _allowDebuggerStatement;
  48. }
  49. }
  50. }