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.
33 using System.Configuration;
34 using System.ComponentModel;
36 namespace System.Web.Configuration
38 public sealed class CompilationSection : ConfigurationSection
40 static ConfigurationPropertyCollection properties;
41 static ConfigurationProperty compilersProp;
42 static ConfigurationProperty tempDirectoryProp;
43 static ConfigurationProperty debugProp;
44 static ConfigurationProperty strictProp;
45 static ConfigurationProperty explicitProp;
46 static ConfigurationProperty batchProp;
47 static ConfigurationProperty batchTimeoutProp;
48 static ConfigurationProperty maxBatchSizeProp;
49 static ConfigurationProperty maxBatchGeneratedFileSizeProp;
50 static ConfigurationProperty numRecompilesBeforeAppRestartProp;
51 static ConfigurationProperty defaultLanguageProp;
52 static ConfigurationProperty assembliesProp;
53 static ConfigurationProperty assemblyPostProcessorTypeProp;
54 static ConfigurationProperty buildProvidersProp;
55 static ConfigurationProperty expressionBuildersProp;
56 static ConfigurationProperty urlLinePragmasProp;
57 static ConfigurationProperty codeSubDirectoriesProp;
58 static ConfigurationProperty optimizeCompilationsProp;
60 static ConfigurationProperty targetFrameworkProp;
63 static CompilationSection ()
65 assembliesProp = new ConfigurationProperty ("assemblies", typeof (AssemblyCollection), null,
66 null, PropertyHelper.DefaultValidator,
67 ConfigurationPropertyOptions.None);
68 assemblyPostProcessorTypeProp = new ConfigurationProperty ("assemblyPostProcessorType", typeof (string), "");
69 batchProp = new ConfigurationProperty ("batch", typeof (bool), true);
70 buildProvidersProp = new ConfigurationProperty ("buildProviders", typeof (BuildProviderCollection), null,
71 null, PropertyHelper.DefaultValidator,
72 ConfigurationPropertyOptions.None);
73 batchTimeoutProp = new ConfigurationProperty ("batchTimeout", typeof (TimeSpan), new TimeSpan (0, 15, 0),
74 PropertyHelper.TimeSpanSecondsOrInfiniteConverter,
75 PropertyHelper.PositiveTimeSpanValidator,
76 ConfigurationPropertyOptions.None);
77 codeSubDirectoriesProp = new ConfigurationProperty ("codeSubDirectories", typeof (CodeSubDirectoriesCollection), null,
78 null, PropertyHelper.DefaultValidator,
79 ConfigurationPropertyOptions.None);
80 compilersProp = new ConfigurationProperty ("compilers", typeof (CompilerCollection), null,
81 null, PropertyHelper.DefaultValidator,
82 ConfigurationPropertyOptions.None);
83 debugProp = new ConfigurationProperty ("debug", typeof (bool), false);
84 defaultLanguageProp = new ConfigurationProperty ("defaultLanguage", typeof (string), "vb");
85 expressionBuildersProp = new ConfigurationProperty ("expressionBuilders", typeof (ExpressionBuilderCollection), null,
86 null, PropertyHelper.DefaultValidator,
87 ConfigurationPropertyOptions.None);
88 explicitProp = new ConfigurationProperty ("explicit", typeof (bool), true);
89 maxBatchSizeProp = new ConfigurationProperty ("maxBatchSize", typeof (int), 1000);
90 maxBatchGeneratedFileSizeProp = new ConfigurationProperty ("maxBatchGeneratedFileSize", typeof (int), 3000);
91 numRecompilesBeforeAppRestartProp = new ConfigurationProperty ("numRecompilesBeforeAppRestart", typeof (int), 15);
92 strictProp = new ConfigurationProperty ("strict", typeof (bool), false);
93 tempDirectoryProp = new ConfigurationProperty ("tempDirectory", typeof (string), "");
94 urlLinePragmasProp = new ConfigurationProperty ("urlLinePragmas", typeof (bool), false);
96 // This is a 4.0 property but it is also supported in 3.5 with
97 // this hotfix: http://support.microsoft.com/kb/961884
98 optimizeCompilationsProp = new ConfigurationProperty ("optimizeCompilations", typeof (bool), false);
101 // Mono ignores this as there is no way to switch the runtime version
102 // dynamically while application is running
103 targetFrameworkProp = new ConfigurationProperty ("targetFramework", typeof (string), null);
106 properties = new ConfigurationPropertyCollection ();
107 properties.Add (assembliesProp);
108 properties.Add (assemblyPostProcessorTypeProp);
109 properties.Add (batchProp);
110 properties.Add (buildProvidersProp);
111 properties.Add (batchTimeoutProp);
112 properties.Add (codeSubDirectoriesProp);
113 properties.Add (compilersProp);
114 properties.Add (debugProp);
115 properties.Add (defaultLanguageProp);
116 properties.Add (expressionBuildersProp);
117 properties.Add (explicitProp);
118 properties.Add (maxBatchSizeProp);
119 properties.Add (maxBatchGeneratedFileSizeProp);
120 properties.Add (numRecompilesBeforeAppRestartProp);
121 properties.Add (strictProp);
122 properties.Add (tempDirectoryProp);
123 properties.Add (urlLinePragmasProp);
124 properties.Add (optimizeCompilationsProp);
126 properties.Add (targetFrameworkProp);
130 public CompilationSection ()
134 protected override void PostDeserialize ()
136 base.PostDeserialize ();
139 [MonoTODO ("why override this?")]
140 protected internal override object GetRuntimeObject ()
145 [ConfigurationProperty ("assemblies")]
146 public AssemblyCollection Assemblies {
147 get { return (AssemblyCollection) base [assembliesProp]; }
150 [ConfigurationProperty ("assemblyPostProcessorType", DefaultValue = "")]
151 public string AssemblyPostProcessorType {
152 get { return (string) base[assemblyPostProcessorTypeProp]; }
153 set { base[assemblyPostProcessorTypeProp] = value; }
156 [ConfigurationProperty ("batch", DefaultValue = "True")]
158 get { return (bool) base [batchProp]; }
159 set { base [batchProp] = value; }
162 [TypeConverter (typeof (TimeSpanSecondsOrInfiniteConverter))]
163 [TimeSpanValidator (MinValueString = "00:00:00")]
164 [ConfigurationProperty ("batchTimeout", DefaultValue = "00:15:00")]
165 public TimeSpan BatchTimeout {
166 get { return (TimeSpan) base [batchTimeoutProp]; }
167 set { base [batchTimeoutProp] = value; }
170 [ConfigurationProperty ("buildProviders")]
171 public BuildProviderCollection BuildProviders {
172 get { return (BuildProviderCollection) base [buildProvidersProp]; }
175 [ConfigurationProperty ("codeSubDirectories")]
176 public CodeSubDirectoriesCollection CodeSubDirectories {
177 get { return (CodeSubDirectoriesCollection) base [codeSubDirectoriesProp]; }
180 [ConfigurationProperty ("compilers")]
181 public CompilerCollection Compilers {
182 get { return (CompilerCollection) base [compilersProp]; }
185 [ConfigurationProperty ("debug", DefaultValue = "False")]
187 get { return (bool) base [debugProp]; }
188 set { base [debugProp] = value; }
191 [ConfigurationProperty ("defaultLanguage", DefaultValue = "vb")]
192 public string DefaultLanguage {
193 get { return (string) base [defaultLanguageProp]; }
194 set { base [defaultLanguageProp] = value; }
197 [ConfigurationProperty ("explicit", DefaultValue = "True")]
198 public bool Explicit {
199 get { return (bool) base [explicitProp]; }
200 set { base [explicitProp] = value; }
203 [ConfigurationProperty ("expressionBuilders")]
204 public ExpressionBuilderCollection ExpressionBuilders {
205 get { return (ExpressionBuilderCollection) base [expressionBuildersProp]; }
208 [ConfigurationProperty ("maxBatchGeneratedFileSize", DefaultValue = "1000")]
209 public int MaxBatchGeneratedFileSize {
210 get { return (int) base [maxBatchGeneratedFileSizeProp]; }
211 set { base [maxBatchGeneratedFileSizeProp] = value; }
214 [ConfigurationProperty ("maxBatchSize", DefaultValue = "1000")]
215 public int MaxBatchSize {
216 get { return (int) base [maxBatchSizeProp]; }
217 set { base [maxBatchSizeProp] = value; }
220 [ConfigurationProperty ("numRecompilesBeforeAppRestart", DefaultValue = "15")]
221 public int NumRecompilesBeforeAppRestart {
222 get { return (int) base [numRecompilesBeforeAppRestartProp]; }
223 set { base [numRecompilesBeforeAppRestartProp] = value; }
226 [ConfigurationProperty ("optimizeCompilations", DefaultValue = "False")]
227 public bool OptimizeCompilations {
228 get { return (bool) base [optimizeCompilationsProp]; }
229 set { base [optimizeCompilationsProp] = value; }
232 [ConfigurationProperty ("strict", DefaultValue = "False")]
234 get { return (bool) base [strictProp]; }
235 set { base [strictProp] = value; }
239 [ConfigurationProperty ("targetFramework", DefaultValue = null)]
240 public string TargetFramework {
241 get { return (string) base [targetFrameworkProp]; }
242 set { base [targetFrameworkProp] = value; }
246 [ConfigurationProperty ("tempDirectory", DefaultValue = "")]
247 public string TempDirectory {
248 get { return (string) base [tempDirectoryProp]; }
249 set { base [tempDirectoryProp] = value; }
252 [ConfigurationProperty ("urlLinePragmas", DefaultValue = "False")]
253 public bool UrlLinePragmas {
254 get { return (bool) base [urlLinePragmasProp]; }
255 set { base [urlLinePragmasProp] = value; }
258 protected internal override ConfigurationPropertyCollection Properties {
259 get { return properties; }