CompilerSettings.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. #if NETSTANDARD || NETCOREAPP
  3. using FastReport.Code.CodeDom.Compiler;
  4. using FastReport.Code.CSharp;
  5. #else
  6. using System.CodeDom.Compiler;
  7. using Microsoft.CSharp;
  8. #endif
  9. using System.Collections.Generic;
  10. using System.IO;
  11. using System.Reflection;
  12. using System.Text;
  13. namespace FastReport.Utils
  14. {
  15. /// <summary>
  16. /// Specifies the behaviour of compiler when exception is thrown.
  17. /// </summary>
  18. public enum CompilerExceptionBehaviour
  19. {
  20. /// <summary>
  21. /// Default behaviour. Throw exception.
  22. /// </summary>
  23. Default,
  24. /// <summary>
  25. /// Show exception message and replace incorrect expression by <b>Placeholder</b>.
  26. /// </summary>
  27. ShowExceptionMessage,
  28. /// <summary>
  29. /// Replace expression with exception message. Don't show any messages.
  30. /// </summary>
  31. ReplaceExpressionWithExceptionMessage,
  32. /// <summary>
  33. /// Replace exception with <b>Placeholder</b> value. Don't show any messages.
  34. /// </summary>
  35. ReplaceExpressionWithPlaceholder
  36. }
  37. /// <summary>
  38. /// Contains compiler settings.
  39. /// </summary>
  40. public class CompilerSettings
  41. {
  42. #region Fields
  43. private string placeholder;
  44. private CompilerExceptionBehaviour exceptionBehaviour;
  45. #endregion Fields
  46. #region Properties
  47. /// <summary>
  48. /// Gets or set the string that will be used for replacing incorrect expressions.
  49. /// </summary>
  50. public string Placeholder
  51. {
  52. get { return placeholder; }
  53. set { placeholder = value; }
  54. }
  55. /// <summary>
  56. /// Gets or sets the behaviour of compiler when exception is thrown.
  57. /// </summary>
  58. public CompilerExceptionBehaviour ExceptionBehaviour
  59. {
  60. get { return exceptionBehaviour; }
  61. set { exceptionBehaviour = value; }
  62. }
  63. #endregion Properties
  64. #region Constructors
  65. /// <summary>
  66. /// Initializes a new instance of the <see cref="CompilerSettings"/> class.
  67. /// </summary>
  68. public CompilerSettings()
  69. {
  70. placeholder = "";
  71. exceptionBehaviour = CompilerExceptionBehaviour.Default;
  72. }
  73. #endregion Constructors
  74. }
  75. }