2 // System.Web.Configuration.CompilerCollection
5 // Chris Toshok (toshok@ximian.com)
7 // (C) 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.
34 using System.CodeDom.Compiler;
35 using System.ComponentModel;
36 using System.Configuration;
38 namespace System.Web.Configuration
40 public sealed class Compiler : ConfigurationElement
42 static ConfigurationProperty compilerOptionsProp;
43 static ConfigurationProperty extensionProp;
44 static ConfigurationProperty languageProp;
45 static ConfigurationProperty typeProp;
46 static ConfigurationProperty warningLevelProp;
48 static ConfigurationPropertyCollection properties;
52 compilerOptionsProp = new ConfigurationProperty("compilerOptions", typeof (string), "");
53 extensionProp = new ConfigurationProperty("extension", typeof (string), "");
54 languageProp = new ConfigurationProperty("language", typeof (string), "", ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
55 typeProp = new ConfigurationProperty("type", typeof (string), "", ConfigurationPropertyOptions.IsRequired);
56 warningLevelProp = new ConfigurationProperty("warningLevel", typeof (int), 0,
57 TypeDescriptor.GetConverter (typeof (int)),
58 new IntegerValidator (0, 4),
59 ConfigurationPropertyOptions.None);
61 properties = new ConfigurationPropertyCollection ();
62 properties.Add (compilerOptionsProp);
63 properties.Add (extensionProp);
64 properties.Add (languageProp);
65 properties.Add (typeProp);
66 properties.Add (warningLevelProp);
73 public Compiler (string compilerOptions, string extension, string language, string type, int warningLevel)
75 this.CompilerOptions = compilerOptions;
76 this.Extension = extension;
77 this.Language = language;
79 this.WarningLevel = warningLevel;
82 [ConfigurationProperty ("compilerOptions", DefaultValue = "")]
83 public string CompilerOptions {
84 get { return (string) base[compilerOptionsProp]; }
85 internal set { base[compilerOptionsProp] = value; }
88 [ConfigurationProperty ("extension", DefaultValue = "")]
89 public string Extension {
90 get { return (string) base[extensionProp]; }
91 internal set { base[extensionProp] = value; }
94 [ConfigurationProperty ("language", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
95 public string Language {
96 get { return (string) base[languageProp]; }
97 internal set { base[languageProp] = value; }
100 [ConfigurationProperty ("type", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired)]
102 get { return (string) base[typeProp]; }
103 internal set { base[typeProp] = value; }
106 [IntegerValidator (MinValue = 0, MaxValue = 4)]
107 [ConfigurationProperty ("warningLevel", DefaultValue = "0")]
108 public int WarningLevel {
109 get { return (int) base[warningLevelProp]; }
110 internal set { base[warningLevelProp] = value; }
113 protected override ConfigurationPropertyCollection Properties {
114 get { return properties; }
117 #region CompatabilityCode
118 [MonoTODO ("we shouldn't need this")]
119 CodeDomProvider provider;
120 internal CodeDomProvider Provider {
122 if (provider == null) {
123 Type t = System.Type.GetType (this.Type);
124 provider = Activator.CreateInstance (t) as CodeDomProvider;