merged Sys.Web.Services 2.0 support in my branch:
[mono.git] / mcs / class / System / System.CodeDom.Compiler / Compiler.cs
1 //
2 // System.Web.Configuration.CompilerCollection
3 //
4 // Authors:
5 //      Chris Toshok (toshok@ximian.com)
6 //
7 // (C) 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 && CONFIGURATION_DEP
32 extern alias PrebuiltSystem;
33 using TypeDescriptor = PrebuiltSystem.System.ComponentModel.TypeDescriptor;
34
35 using System;
36 using System.ComponentModel;
37 using System.Configuration;
38
39 namespace System.CodeDom.Compiler
40 {
41         internal sealed class Compiler : ConfigurationElement
42         {
43                 static ConfigurationProperty compilerOptionsProp;
44                 static ConfigurationProperty extensionProp;
45                 static ConfigurationProperty languageProp;
46                 static ConfigurationProperty typeProp;
47                 static ConfigurationProperty warningLevelProp;
48
49                 static ConfigurationPropertyCollection properties;
50
51                 static Compiler ()
52                 {
53                         compilerOptionsProp = new ConfigurationProperty("compilerOptions", typeof (string), "");
54                         extensionProp = new ConfigurationProperty("extension", typeof (string), "");
55                         languageProp = new ConfigurationProperty("language", typeof (string), "", ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
56                         typeProp = new ConfigurationProperty("type", typeof (string), "", ConfigurationPropertyOptions.IsRequired);
57                         warningLevelProp = new ConfigurationProperty("warningLevel", typeof (int), 0,
58                                                                      TypeDescriptor.GetConverter (typeof (int)),
59                                                                      new IntegerValidator (0, 4),
60                                                                      ConfigurationPropertyOptions.None);
61
62                         properties = new ConfigurationPropertyCollection ();
63                         properties.Add (compilerOptionsProp);
64                         properties.Add (extensionProp);
65                         properties.Add (languageProp);
66                         properties.Add (typeProp);
67                         properties.Add (warningLevelProp);
68                 }
69
70                 internal Compiler ()
71                 {
72                 }
73
74                 public Compiler (string compilerOptions, string extension, string language, string type, int warningLevel)
75                 {
76                         this.CompilerOptions = compilerOptions;
77                         this.Extension = extension;
78                         this.Language = language;
79                         this.Type = type;
80                         this.WarningLevel = warningLevel;
81                 }
82
83                 [ConfigurationProperty ("compilerOptions", DefaultValue = "")]
84                 public string CompilerOptions {
85                         get { return (string) base[compilerOptionsProp]; }
86                         internal set { base[compilerOptionsProp] = value; }
87                 }
88
89                 [ConfigurationProperty ("extension", DefaultValue = "")]
90                 public string Extension {
91                         get { return (string) base[extensionProp]; }
92                         internal set { base[extensionProp] = value; }
93                 }
94
95                 [ConfigurationProperty ("language", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
96                 public string Language {
97                         get { return (string) base[languageProp]; }
98                         internal set { base[languageProp] = value; }
99                 }
100
101                 [ConfigurationProperty ("type", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired)]
102                 public string Type {
103                         get { return (string) base[typeProp]; }
104                         internal set { base[typeProp] = value; }
105                 }
106
107                 [IntegerValidator (MinValue = 0, MaxValue = 4)]
108                 [ConfigurationProperty ("warningLevel", DefaultValue = "0")]
109                 public int WarningLevel {
110                         get { return (int) base[warningLevelProp]; }
111                         internal set { base[warningLevelProp] = value; }
112                 }
113
114                 protected override ConfigurationPropertyCollection Properties {
115                         get { return properties; }
116                 }
117         }
118 }
119 #endif