Compiler.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //
  2. // System.Web.Configuration.CompilerCollection
  3. //
  4. // Authors:
  5. // Chris Toshok ([email protected])
  6. //
  7. // (C) 2005 Novell, Inc (http://www.novell.com)
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if CONFIGURATION_DEP
  30. using System;
  31. using System.Collections.Generic;
  32. using System.ComponentModel;
  33. using System.Configuration;
  34. namespace System.CodeDom.Compiler
  35. {
  36. internal sealed class Compiler : ConfigurationElement
  37. {
  38. static ConfigurationProperty compilerOptionsProp;
  39. static ConfigurationProperty extensionProp;
  40. static ConfigurationProperty languageProp;
  41. static ConfigurationProperty typeProp;
  42. static ConfigurationProperty warningLevelProp;
  43. static ConfigurationProperty providerOptionsProp;
  44. static ConfigurationPropertyCollection properties;
  45. static Compiler ()
  46. {
  47. compilerOptionsProp = new ConfigurationProperty("compilerOptions", typeof (string), "");
  48. extensionProp = new ConfigurationProperty("extension", typeof (string), "");
  49. languageProp = new ConfigurationProperty("language", typeof (string), "", ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
  50. typeProp = new ConfigurationProperty("type", typeof (string), "", ConfigurationPropertyOptions.IsRequired);
  51. warningLevelProp = new ConfigurationProperty("warningLevel", typeof (int), 0,
  52. TypeDescriptor.GetConverter (typeof (int)),
  53. new IntegerValidator (0, 4),
  54. ConfigurationPropertyOptions.None);
  55. providerOptionsProp = new ConfigurationProperty ("", typeof (CompilerProviderOptionsCollection), null, null, null,
  56. ConfigurationPropertyOptions.IsDefaultCollection);
  57. properties = new ConfigurationPropertyCollection ();
  58. properties.Add (compilerOptionsProp);
  59. properties.Add (extensionProp);
  60. properties.Add (languageProp);
  61. properties.Add (typeProp);
  62. properties.Add (warningLevelProp);
  63. properties.Add (providerOptionsProp);
  64. }
  65. internal Compiler ()
  66. {
  67. }
  68. public Compiler (string compilerOptions, string extension, string language, string type, int warningLevel)
  69. {
  70. this.CompilerOptions = compilerOptions;
  71. this.Extension = extension;
  72. this.Language = language;
  73. this.Type = type;
  74. this.WarningLevel = warningLevel;
  75. }
  76. [ConfigurationProperty ("compilerOptions", DefaultValue = "")]
  77. public string CompilerOptions {
  78. get { return (string) base[compilerOptionsProp]; }
  79. internal set { base[compilerOptionsProp] = value; }
  80. }
  81. [ConfigurationProperty ("extension", DefaultValue = "")]
  82. public string Extension {
  83. get { return (string) base[extensionProp]; }
  84. internal set { base[extensionProp] = value; }
  85. }
  86. [ConfigurationProperty ("language", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
  87. public string Language {
  88. get { return (string) base[languageProp]; }
  89. internal set { base[languageProp] = value; }
  90. }
  91. [ConfigurationProperty ("type", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired)]
  92. public string Type {
  93. get { return (string) base[typeProp]; }
  94. internal set { base[typeProp] = value; }
  95. }
  96. [IntegerValidator (MinValue = 0, MaxValue = 4)]
  97. [ConfigurationProperty ("warningLevel", DefaultValue = "0")]
  98. public int WarningLevel {
  99. get { return (int) base[warningLevelProp]; }
  100. internal set { base[warningLevelProp] = value; }
  101. }
  102. [ConfigurationProperty ("", Options = ConfigurationPropertyOptions.IsDefaultCollection)]
  103. public CompilerProviderOptionsCollection ProviderOptions {
  104. get { return (CompilerProviderOptionsCollection) base [providerOptionsProp]; }
  105. internal set { base [providerOptionsProp] = value; }
  106. }
  107. public Dictionary <string, string> ProviderOptionsDictionary {
  108. get { return ProviderOptions.ProviderOptions; }
  109. }
  110. protected override ConfigurationPropertyCollection Properties {
  111. get { return properties; }
  112. }
  113. }
  114. }
  115. #endif