Merge pull request #1304 from slluis/mac-proxy-autoconfig
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / CompilationSection.cs
1 //
2 // System.Web.Configuration.CompilationSection
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // (c) Copyright 2005 Novell, Inc (http://www.novell.com)
8 //
9
10 //
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:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
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.
29 //
30
31 #if NET_2_0
32 using System;
33 using System.Configuration;
34 using System.ComponentModel;
35
36 namespace System.Web.Configuration
37 {
38         public sealed class CompilationSection : ConfigurationSection
39         {
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;
59 #if NET_4_0
60                 static ConfigurationProperty targetFrameworkProp;
61 #endif
62                 
63                 static CompilationSection ()
64                 {
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);
95
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);
99
100 #if NET_4_0
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);
104 #endif
105
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);
125 #if NET_4_0
126                         properties.Add (targetFrameworkProp);
127 #endif
128                 }
129
130                 public CompilationSection ()
131                 {
132                 }
133
134                 protected override void PostDeserialize ()
135                 {
136                         base.PostDeserialize ();
137                 }
138
139                 [MonoTODO ("why override this?")]
140                 protected internal override object GetRuntimeObject ()
141                 {
142                         return this;
143                 }
144
145                 [ConfigurationProperty ("assemblies")]
146                 public AssemblyCollection Assemblies {
147                         get { return (AssemblyCollection) base [assembliesProp]; }
148                 }
149
150                 [ConfigurationProperty ("assemblyPostProcessorType", DefaultValue = "")]
151                 public string AssemblyPostProcessorType {
152                         get { return (string) base[assemblyPostProcessorTypeProp]; }
153                         set { base[assemblyPostProcessorTypeProp] = value; }
154                 }
155
156                 [ConfigurationProperty ("batch", DefaultValue = "True")]
157                 public bool Batch {
158                         get { return (bool) base [batchProp]; }
159                         set { base [batchProp] = value; }
160                 }
161
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; }
168                 }
169
170                 [ConfigurationProperty ("buildProviders")]
171                 public BuildProviderCollection BuildProviders {
172                         get { return (BuildProviderCollection) base [buildProvidersProp]; }
173                 }
174
175                 [ConfigurationProperty ("codeSubDirectories")]
176                 public CodeSubDirectoriesCollection CodeSubDirectories {
177                         get { return (CodeSubDirectoriesCollection) base [codeSubDirectoriesProp]; }
178                 }
179
180                 [ConfigurationProperty ("compilers")]
181                 public CompilerCollection Compilers {
182                         get { return (CompilerCollection) base [compilersProp]; }
183                 }
184
185                 [ConfigurationProperty ("debug", DefaultValue = "False")]
186                 public bool Debug {
187                         get { return (bool) base [debugProp]; }
188                         set { base [debugProp] = value; }
189                 }
190
191                 [ConfigurationProperty ("defaultLanguage", DefaultValue = "vb")]
192                 public string DefaultLanguage {
193                         get { return (string) base [defaultLanguageProp]; }
194                         set { base [defaultLanguageProp] = value; }
195                 }
196
197                 [ConfigurationProperty ("explicit", DefaultValue = "True")]
198                 public bool Explicit {
199                         get { return (bool) base [explicitProp]; }
200                         set { base [explicitProp] = value; }
201                 }
202
203                 [ConfigurationProperty ("expressionBuilders")]
204                 public ExpressionBuilderCollection ExpressionBuilders {
205                         get { return (ExpressionBuilderCollection) base [expressionBuildersProp]; }
206                 }
207
208                 [ConfigurationProperty ("maxBatchGeneratedFileSize", DefaultValue = "1000")]
209                 public int MaxBatchGeneratedFileSize {
210                         get { return (int) base [maxBatchGeneratedFileSizeProp]; }
211                         set { base [maxBatchGeneratedFileSizeProp] = value; }
212                 }
213
214                 [ConfigurationProperty ("maxBatchSize", DefaultValue = "1000")]
215                 public int MaxBatchSize {
216                         get { return (int) base [maxBatchSizeProp]; }
217                         set { base [maxBatchSizeProp] = value; }
218                 }
219
220                 [ConfigurationProperty ("numRecompilesBeforeAppRestart", DefaultValue = "15")]
221                 public int NumRecompilesBeforeAppRestart {
222                         get { return (int) base [numRecompilesBeforeAppRestartProp]; }
223                         set { base [numRecompilesBeforeAppRestartProp] = value; }
224                 }
225
226                 [ConfigurationProperty ("optimizeCompilations", DefaultValue = "False")]
227                 public bool OptimizeCompilations {
228                         get { return (bool) base [optimizeCompilationsProp]; }
229                         set { base [optimizeCompilationsProp] = value; }
230                 }
231                 
232                 [ConfigurationProperty ("strict", DefaultValue = "False")]
233                 public bool Strict {
234                         get { return (bool) base [strictProp]; }
235                         set { base [strictProp] = value; }
236                 }
237
238 #if NET_4_0
239                 [ConfigurationProperty ("targetFramework", DefaultValue = null)]
240                 public string TargetFramework {
241                         get { return (string) base [targetFrameworkProp]; }
242                         set { base [targetFrameworkProp] = value; }
243                 }
244 #endif
245                 
246                 [ConfigurationProperty ("tempDirectory", DefaultValue = "")]
247                 public string TempDirectory {
248                         get { return (string) base [tempDirectoryProp]; }
249                         set { base [tempDirectoryProp] = value; }
250                 }
251
252                 [ConfigurationProperty ("urlLinePragmas", DefaultValue = "False")]
253                 public bool UrlLinePragmas {
254                         get { return (bool) base [urlLinePragmasProp]; }
255                         set { base [urlLinePragmasProp] = value; }
256                 }
257
258                 protected internal override ConfigurationPropertyCollection Properties {
259                         get { return properties; }
260                 }
261         }
262 }
263 #endif // NET_2_0
264