2 // System.Web.Configuration.CompilationSection
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // (c) Copyright 2005 Novell, Inc (http://www.novell.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Configuration;
33 using System.ComponentModel;
35 namespace System.Web.Configuration
37 public sealed class CompilationSection : ConfigurationSection
39 static ConfigurationPropertyCollection properties;
40 static ConfigurationProperty compilersProp;
41 static ConfigurationProperty tempDirectoryProp;
42 static ConfigurationProperty debugProp;
43 static ConfigurationProperty strictProp;
44 static ConfigurationProperty explicitProp;
45 static ConfigurationProperty batchProp;
46 static ConfigurationProperty batchTimeoutProp;
47 static ConfigurationProperty maxBatchSizeProp;
48 static ConfigurationProperty maxBatchGeneratedFileSizeProp;
49 static ConfigurationProperty numRecompilesBeforeAppRestartProp;
50 static ConfigurationProperty defaultLanguageProp;
51 static ConfigurationProperty assembliesProp;
52 static ConfigurationProperty assemblyPostProcessorTypeProp;
53 static ConfigurationProperty buildProvidersProp;
54 static ConfigurationProperty expressionBuildersProp;
55 static ConfigurationProperty urlLinePragmasProp;
56 static ConfigurationProperty codeSubDirectoriesProp;
57 static ConfigurationProperty optimizeCompilationsProp;
58 static ConfigurationProperty targetFrameworkProp;
60 static CompilationSection ()
62 assembliesProp = new ConfigurationProperty ("assemblies", typeof (AssemblyCollection), null,
63 null, PropertyHelper.DefaultValidator,
64 ConfigurationPropertyOptions.None);
65 assemblyPostProcessorTypeProp = new ConfigurationProperty ("assemblyPostProcessorType", typeof (string), "");
66 batchProp = new ConfigurationProperty ("batch", typeof (bool), true);
67 buildProvidersProp = new ConfigurationProperty ("buildProviders", typeof (BuildProviderCollection), null,
68 null, PropertyHelper.DefaultValidator,
69 ConfigurationPropertyOptions.None);
70 batchTimeoutProp = new ConfigurationProperty ("batchTimeout", typeof (TimeSpan), new TimeSpan (0, 15, 0),
71 PropertyHelper.TimeSpanSecondsOrInfiniteConverter,
72 PropertyHelper.PositiveTimeSpanValidator,
73 ConfigurationPropertyOptions.None);
74 codeSubDirectoriesProp = new ConfigurationProperty ("codeSubDirectories", typeof (CodeSubDirectoriesCollection), null,
75 null, PropertyHelper.DefaultValidator,
76 ConfigurationPropertyOptions.None);
77 compilersProp = new ConfigurationProperty ("compilers", typeof (CompilerCollection), null,
78 null, PropertyHelper.DefaultValidator,
79 ConfigurationPropertyOptions.None);
80 debugProp = new ConfigurationProperty ("debug", typeof (bool), false);
81 defaultLanguageProp = new ConfigurationProperty ("defaultLanguage", typeof (string), "vb");
82 expressionBuildersProp = new ConfigurationProperty ("expressionBuilders", typeof (ExpressionBuilderCollection), null,
83 null, PropertyHelper.DefaultValidator,
84 ConfigurationPropertyOptions.None);
85 explicitProp = new ConfigurationProperty ("explicit", typeof (bool), true);
86 maxBatchSizeProp = new ConfigurationProperty ("maxBatchSize", typeof (int), 1000);
87 maxBatchGeneratedFileSizeProp = new ConfigurationProperty ("maxBatchGeneratedFileSize", typeof (int), 3000);
88 numRecompilesBeforeAppRestartProp = new ConfigurationProperty ("numRecompilesBeforeAppRestart", typeof (int), 15);
89 strictProp = new ConfigurationProperty ("strict", typeof (bool), false);
90 tempDirectoryProp = new ConfigurationProperty ("tempDirectory", typeof (string), "");
91 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);
97 // Mono ignores this as there is no way to switch the runtime version
98 // dynamically while application is running
99 targetFrameworkProp = new ConfigurationProperty ("targetFramework", typeof (string), null);
101 properties = new ConfigurationPropertyCollection ();
102 properties.Add (assembliesProp);
103 properties.Add (assemblyPostProcessorTypeProp);
104 properties.Add (batchProp);
105 properties.Add (buildProvidersProp);
106 properties.Add (batchTimeoutProp);
107 properties.Add (codeSubDirectoriesProp);
108 properties.Add (compilersProp);
109 properties.Add (debugProp);
110 properties.Add (defaultLanguageProp);
111 properties.Add (expressionBuildersProp);
112 properties.Add (explicitProp);
113 properties.Add (maxBatchSizeProp);
114 properties.Add (maxBatchGeneratedFileSizeProp);
115 properties.Add (numRecompilesBeforeAppRestartProp);
116 properties.Add (strictProp);
117 properties.Add (tempDirectoryProp);
118 properties.Add (urlLinePragmasProp);
119 properties.Add (optimizeCompilationsProp);
120 properties.Add (targetFrameworkProp);
123 public CompilationSection ()
127 protected override void PostDeserialize ()
129 base.PostDeserialize ();
132 [MonoTODO ("why override this?")]
133 protected internal override object GetRuntimeObject ()
138 [ConfigurationProperty ("assemblies")]
139 public AssemblyCollection Assemblies {
140 get { return (AssemblyCollection) base [assembliesProp]; }
143 [ConfigurationProperty ("assemblyPostProcessorType", DefaultValue = "")]
144 public string AssemblyPostProcessorType {
145 get { return (string) base[assemblyPostProcessorTypeProp]; }
146 set { base[assemblyPostProcessorTypeProp] = value; }
149 [ConfigurationProperty ("batch", DefaultValue = "True")]
151 get { return (bool) base [batchProp]; }
152 set { base [batchProp] = value; }
155 [TypeConverter (typeof (TimeSpanSecondsOrInfiniteConverter))]
156 [TimeSpanValidator (MinValueString = "00:00:00")]
157 [ConfigurationProperty ("batchTimeout", DefaultValue = "00:15:00")]
158 public TimeSpan BatchTimeout {
159 get { return (TimeSpan) base [batchTimeoutProp]; }
160 set { base [batchTimeoutProp] = value; }
163 [ConfigurationProperty ("buildProviders")]
164 public BuildProviderCollection BuildProviders {
165 get { return (BuildProviderCollection) base [buildProvidersProp]; }
168 [ConfigurationProperty ("codeSubDirectories")]
169 public CodeSubDirectoriesCollection CodeSubDirectories {
170 get { return (CodeSubDirectoriesCollection) base [codeSubDirectoriesProp]; }
173 [ConfigurationProperty ("compilers")]
174 public CompilerCollection Compilers {
175 get { return (CompilerCollection) base [compilersProp]; }
178 [ConfigurationProperty ("debug", DefaultValue = "False")]
180 get { return (bool) base [debugProp]; }
181 set { base [debugProp] = value; }
184 [ConfigurationProperty ("defaultLanguage", DefaultValue = "vb")]
185 public string DefaultLanguage {
186 get { return (string) base [defaultLanguageProp]; }
187 set { base [defaultLanguageProp] = value; }
190 [ConfigurationProperty ("explicit", DefaultValue = "True")]
191 public bool Explicit {
192 get { return (bool) base [explicitProp]; }
193 set { base [explicitProp] = value; }
196 [ConfigurationProperty ("expressionBuilders")]
197 public ExpressionBuilderCollection ExpressionBuilders {
198 get { return (ExpressionBuilderCollection) base [expressionBuildersProp]; }
201 [ConfigurationProperty ("maxBatchGeneratedFileSize", DefaultValue = "1000")]
202 public int MaxBatchGeneratedFileSize {
203 get { return (int) base [maxBatchGeneratedFileSizeProp]; }
204 set { base [maxBatchGeneratedFileSizeProp] = value; }
207 [ConfigurationProperty ("maxBatchSize", DefaultValue = "1000")]
208 public int MaxBatchSize {
209 get { return (int) base [maxBatchSizeProp]; }
210 set { base [maxBatchSizeProp] = value; }
213 [ConfigurationProperty ("numRecompilesBeforeAppRestart", DefaultValue = "15")]
214 public int NumRecompilesBeforeAppRestart {
215 get { return (int) base [numRecompilesBeforeAppRestartProp]; }
216 set { base [numRecompilesBeforeAppRestartProp] = value; }
219 [ConfigurationProperty ("optimizeCompilations", DefaultValue = "False")]
220 public bool OptimizeCompilations {
221 get { return (bool) base [optimizeCompilationsProp]; }
222 set { base [optimizeCompilationsProp] = value; }
225 [ConfigurationProperty ("strict", DefaultValue = "False")]
227 get { return (bool) base [strictProp]; }
228 set { base [strictProp] = value; }
231 [ConfigurationProperty ("targetFramework", DefaultValue = null)]
232 public string TargetFramework {
233 get { return (string) base [targetFrameworkProp]; }
234 set { base [targetFrameworkProp] = value; }
237 [ConfigurationProperty ("tempDirectory", DefaultValue = "")]
238 public string TempDirectory {
239 get { return (string) base [tempDirectoryProp]; }
240 set { base [tempDirectoryProp] = value; }
243 [ConfigurationProperty ("urlLinePragmas", DefaultValue = "False")]
244 public bool UrlLinePragmas {
245 get { return (bool) base [urlLinePragmasProp]; }
246 set { base [urlLinePragmasProp] = value; }
249 protected internal override ConfigurationPropertyCollection Properties {
250 get { return properties; }