CodeGeneratorOptions.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. //
  2. // System.CodeDom.Compiler CodeGeneratorOptions class
  3. //
  4. // Author:
  5. // Daniel Stodden ([email protected])
  6. //
  7. // (C) 2002 Ximian, Inc.
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System;
  30. using System.Collections;
  31. using System.Collections.Specialized;
  32. namespace System.CodeDom.Compiler
  33. {
  34. public class CodeGeneratorOptions
  35. {
  36. private IDictionary properties;
  37. //
  38. // Constructors
  39. //
  40. public CodeGeneratorOptions()
  41. {
  42. properties = new ListDictionary();
  43. properties.Add( "BlankLinesBetweenMembers", true );
  44. properties.Add( "BracingStyle", "Block" );
  45. properties.Add( "ElseOnClosing", false );
  46. properties.Add( "IndentString", " " );
  47. #if NET_2_0
  48. properties.Add( "VerbatimOrder", false );
  49. #endif
  50. }
  51. //
  52. // Properties
  53. //
  54. /// <summary>
  55. /// Whether to insert blank lines between individual members.
  56. /// Default is true.
  57. /// </summary>
  58. public bool BlankLinesBetweenMembers {
  59. get {
  60. return (bool)properties["BlankLinesBetweenMembers"];
  61. }
  62. set {
  63. properties["BlankLinesBetweenMembers"] = value;
  64. }
  65. }
  66. /// <summary>
  67. /// "Block" puts braces on the same line as the associated statement or declaration.
  68. /// "C" puts braces on the following line.
  69. /// Default is "C"
  70. /// </summary>
  71. public string BracingStyle {
  72. get {
  73. return (string)properties["BracingStyle"];
  74. }
  75. set {
  76. properties["BracingStyle"] = value;
  77. }
  78. }
  79. /// <summary>
  80. /// Whether to start <code>else</code>,
  81. /// <code>catch</code>, or <code>finally</code>
  82. /// blocks on the same line as the previous block.
  83. /// Default is false.
  84. /// </summary>
  85. public bool ElseOnClosing {
  86. get {
  87. return (bool)properties["ElseOnClosing"];
  88. }
  89. set {
  90. properties["ElseOnClosing"] = value;
  91. }
  92. }
  93. /// <summary>
  94. /// The string used for individual indentation levels. Default is four spaces.
  95. /// </summary>
  96. public string IndentString {
  97. get {
  98. return (string)properties["IndentString"];
  99. }
  100. set {
  101. properties["IndentString"] = value;
  102. }
  103. }
  104. public Object this[string index] {
  105. get {
  106. return properties[index];
  107. }
  108. set {
  109. properties[index] = value;
  110. }
  111. }
  112. #if NET_2_0
  113. public bool VerbatimOrder {
  114. get {
  115. return (bool)properties["VerbatimOrder"];
  116. }
  117. set {
  118. properties["VerbatimOrder"] = value;
  119. }
  120. }
  121. #endif
  122. }
  123. }