CompilationSection.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. //
  2. // System.Web.Configuration.CompilationSection
  3. //
  4. // Authors:
  5. // Gonzalo Paniagua Javier ([email protected])
  6. //
  7. // (c) Copyright 2005 Novell, Inc (http://www.novell.com)
  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. #if NET_2_0
  30. using System;
  31. using System.Configuration;
  32. using System.ComponentModel;
  33. namespace System.Web.Configuration
  34. {
  35. public sealed class CompilationSection : ConfigurationSection
  36. {
  37. static ConfigurationPropertyCollection properties;
  38. static ConfigurationProperty compilersProp;
  39. static ConfigurationProperty tempDirectoryProp;
  40. static ConfigurationProperty debugProp;
  41. static ConfigurationProperty strictProp;
  42. static ConfigurationProperty explicitProp;
  43. static ConfigurationProperty batchProp;
  44. static ConfigurationProperty batchTimeoutProp;
  45. static ConfigurationProperty maxBatchSizeProp;
  46. static ConfigurationProperty maxBatchGeneratedFileSizeProp;
  47. static ConfigurationProperty numRecompilesBeforeAppRestartProp;
  48. static ConfigurationProperty defaultLanguageProp;
  49. static ConfigurationProperty assembliesProp;
  50. static ConfigurationProperty assemblyPostProcessorTypeProp;
  51. static ConfigurationProperty buildProvidersProp;
  52. static ConfigurationProperty expressionBuildersProp;
  53. static ConfigurationProperty urlLinePragmasProp;
  54. static ConfigurationProperty codeSubDirectoriesProp;
  55. static ConfigurationProperty optimizeCompilationsProp;
  56. #if NET_4_0
  57. static ConfigurationProperty targetNetworkProp;
  58. #endif
  59. static CompilationSection ()
  60. {
  61. assembliesProp = new ConfigurationProperty ("assemblies", typeof (AssemblyCollection), null,
  62. null, PropertyHelper.DefaultValidator,
  63. ConfigurationPropertyOptions.None);
  64. assemblyPostProcessorTypeProp = new ConfigurationProperty ("assemblyPostProcessorType", typeof (string), "");
  65. batchProp = new ConfigurationProperty ("batch", typeof (bool), true);
  66. #if !TARGET_JVM
  67. buildProvidersProp = new ConfigurationProperty ("buildProviders", typeof (BuildProviderCollection), null,
  68. null, PropertyHelper.DefaultValidator,
  69. ConfigurationPropertyOptions.None);
  70. #endif
  71. batchTimeoutProp = new ConfigurationProperty ("batchTimeout", typeof (TimeSpan), new TimeSpan (0, 15, 0),
  72. PropertyHelper.TimeSpanSecondsOrInfiniteConverter,
  73. PropertyHelper.PositiveTimeSpanValidator,
  74. ConfigurationPropertyOptions.None);
  75. codeSubDirectoriesProp = new ConfigurationProperty ("codeSubDirectories", typeof (CodeSubDirectoriesCollection), null,
  76. null, PropertyHelper.DefaultValidator,
  77. ConfigurationPropertyOptions.None);
  78. compilersProp = new ConfigurationProperty ("compilers", typeof (CompilerCollection), null,
  79. null, PropertyHelper.DefaultValidator,
  80. ConfigurationPropertyOptions.None);
  81. debugProp = new ConfigurationProperty ("debug", typeof (bool), false);
  82. defaultLanguageProp = new ConfigurationProperty ("defaultLanguage", typeof (string), "vb");
  83. expressionBuildersProp = new ConfigurationProperty ("expressionBuilders", typeof (ExpressionBuilderCollection), null,
  84. null, PropertyHelper.DefaultValidator,
  85. ConfigurationPropertyOptions.None);
  86. explicitProp = new ConfigurationProperty ("explicit", typeof (bool), true);
  87. maxBatchSizeProp = new ConfigurationProperty ("maxBatchSize", typeof (int), 1000);
  88. maxBatchGeneratedFileSizeProp = new ConfigurationProperty ("maxBatchGeneratedFileSize", typeof (int), 3000);
  89. numRecompilesBeforeAppRestartProp = new ConfigurationProperty ("numRecompilesBeforeAppRestart", typeof (int), 15);
  90. strictProp = new ConfigurationProperty ("strict", typeof (bool), false);
  91. tempDirectoryProp = new ConfigurationProperty ("tempDirectory", typeof (string), "");
  92. urlLinePragmasProp = new ConfigurationProperty ("urlLinePragmas", typeof (bool), false);
  93. // This is a 4.0 property but it is also supported in 3.5 with
  94. // this hotfix: http://support.microsoft.com/kb/961884
  95. optimizeCompilationsProp = new ConfigurationProperty ("optimizeCompilations", typeof (bool), false);
  96. #if NET_4_0
  97. // Mono ignores this as there is no way to switch the runtime version
  98. // dynamically while application is running
  99. targetNetworkProp = new ConfigurationProperty ("targetNetwork", typeof (string), null);
  100. #endif
  101. properties = new ConfigurationPropertyCollection ();
  102. properties.Add (assembliesProp);
  103. properties.Add (assemblyPostProcessorTypeProp);
  104. properties.Add (batchProp);
  105. #if !TARGET_JVM
  106. properties.Add (buildProvidersProp);
  107. #endif
  108. properties.Add (batchTimeoutProp);
  109. properties.Add (codeSubDirectoriesProp);
  110. properties.Add (compilersProp);
  111. properties.Add (debugProp);
  112. properties.Add (defaultLanguageProp);
  113. properties.Add (expressionBuildersProp);
  114. properties.Add (explicitProp);
  115. properties.Add (maxBatchSizeProp);
  116. properties.Add (maxBatchGeneratedFileSizeProp);
  117. properties.Add (numRecompilesBeforeAppRestartProp);
  118. properties.Add (strictProp);
  119. properties.Add (tempDirectoryProp);
  120. properties.Add (urlLinePragmasProp);
  121. properties.Add (optimizeCompilationsProp);
  122. #if NET_4_0
  123. properties.Add (targetNetworkProp);
  124. #endif
  125. }
  126. public CompilationSection ()
  127. {
  128. }
  129. protected override void PostDeserialize ()
  130. {
  131. base.PostDeserialize ();
  132. }
  133. [MonoTODO ("why override this?")]
  134. protected override object GetRuntimeObject ()
  135. {
  136. return this;
  137. }
  138. [ConfigurationProperty ("assemblies")]
  139. public AssemblyCollection Assemblies {
  140. get { return (AssemblyCollection) base [assembliesProp]; }
  141. }
  142. [ConfigurationProperty ("assemblyPostProcessorType", DefaultValue = "")]
  143. public string AssemblyPostProcessorType {
  144. get { return (string) base[assemblyPostProcessorTypeProp]; }
  145. set { base[assemblyPostProcessorTypeProp] = value; }
  146. }
  147. [ConfigurationProperty ("batch", DefaultValue = "True")]
  148. public bool Batch {
  149. get { return (bool) base [batchProp]; }
  150. set { base [batchProp] = value; }
  151. }
  152. [TypeConverter (typeof (TimeSpanSecondsOrInfiniteConverter))]
  153. [TimeSpanValidator (MinValueString = "00:00:00")]
  154. [ConfigurationProperty ("batchTimeout", DefaultValue = "00:15:00")]
  155. public TimeSpan BatchTimeout {
  156. get { return (TimeSpan) base [batchTimeoutProp]; }
  157. set { base [batchTimeoutProp] = value; }
  158. }
  159. #if !TARGET_JVM
  160. [ConfigurationProperty ("buildProviders")]
  161. public BuildProviderCollection BuildProviders {
  162. get { return (BuildProviderCollection) base [buildProvidersProp]; }
  163. }
  164. #endif
  165. [ConfigurationProperty ("codeSubDirectories")]
  166. public CodeSubDirectoriesCollection CodeSubDirectories {
  167. get { return (CodeSubDirectoriesCollection) base [codeSubDirectoriesProp]; }
  168. }
  169. [ConfigurationProperty ("compilers")]
  170. public CompilerCollection Compilers {
  171. get { return (CompilerCollection) base [compilersProp]; }
  172. }
  173. [ConfigurationProperty ("debug", DefaultValue = "False")]
  174. public bool Debug {
  175. get { return (bool) base [debugProp]; }
  176. set { base [debugProp] = value; }
  177. }
  178. [ConfigurationProperty ("defaultLanguage", DefaultValue = "vb")]
  179. public string DefaultLanguage {
  180. get { return (string) base [defaultLanguageProp]; }
  181. set { base [defaultLanguageProp] = value; }
  182. }
  183. [ConfigurationProperty ("explicit", DefaultValue = "True")]
  184. public bool Explicit {
  185. get { return (bool) base [explicitProp]; }
  186. set { base [explicitProp] = value; }
  187. }
  188. [ConfigurationProperty ("expressionBuilders")]
  189. public ExpressionBuilderCollection ExpressionBuilders {
  190. get { return (ExpressionBuilderCollection) base [expressionBuildersProp]; }
  191. }
  192. [ConfigurationProperty ("maxBatchGeneratedFileSize", DefaultValue = "1000")]
  193. public int MaxBatchGeneratedFileSize {
  194. get { return (int) base [maxBatchGeneratedFileSizeProp]; }
  195. set { base [maxBatchGeneratedFileSizeProp] = value; }
  196. }
  197. [ConfigurationProperty ("maxBatchSize", DefaultValue = "1000")]
  198. public int MaxBatchSize {
  199. get { return (int) base [maxBatchSizeProp]; }
  200. set { base [maxBatchSizeProp] = value; }
  201. }
  202. [ConfigurationProperty ("numRecompilesBeforeAppRestart", DefaultValue = "15")]
  203. public int NumRecompilesBeforeAppRestart {
  204. get { return (int) base [numRecompilesBeforeAppRestartProp]; }
  205. set { base [numRecompilesBeforeAppRestartProp] = value; }
  206. }
  207. [ConfigurationProperty ("optimizeCompilations", DefaultValue = "False")]
  208. public bool OptimizeCompilations {
  209. get { return (bool) base [optimizeCompilationsProp]; }
  210. set { base [optimizeCompilationsProp] = value; }
  211. }
  212. [ConfigurationProperty ("strict", DefaultValue = "False")]
  213. public bool Strict {
  214. get { return (bool) base [strictProp]; }
  215. set { base [strictProp] = value; }
  216. }
  217. #if NET_4_0
  218. [ConfigurationProperty ("targetNetwork", DefaultValue = null)]
  219. public string TargetNetwork {
  220. get { return (string) base [targetNetworkProp]; }
  221. set { base [targetNetworkProp] = value; }
  222. }
  223. #endif
  224. [ConfigurationProperty ("tempDirectory", DefaultValue = "")]
  225. public string TempDirectory {
  226. get { return (string) base [tempDirectoryProp]; }
  227. set { base [tempDirectoryProp] = value; }
  228. }
  229. [ConfigurationProperty ("urlLinePragmas", DefaultValue = "False")]
  230. public bool UrlLinePragmas {
  231. get { return (bool) base [urlLinePragmasProp]; }
  232. set { base [urlLinePragmasProp] = value; }
  233. }
  234. protected override ConfigurationPropertyCollection Properties {
  235. get { return properties; }
  236. }
  237. }
  238. }
  239. #endif // NET_2_0