2
0

CodeDomProvider.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // System.CodeDom.Compiler.CodeDomProvider.cs
  3. //
  4. // Author:
  5. // Daniel Stodden ([email protected])
  6. // Marek Safar ([email protected])
  7. //
  8. // (C) 2002 Ximian, Inc.
  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. using System.ComponentModel;
  31. using System.IO;
  32. namespace System.CodeDom.Compiler
  33. {
  34. [ToolboxItem ("")]
  35. public abstract class CodeDomProvider : Component
  36. {
  37. //
  38. // Constructors
  39. //
  40. protected CodeDomProvider()
  41. {
  42. }
  43. //
  44. // Properties
  45. //
  46. public virtual string FileExtension {
  47. get {
  48. return String.Empty;
  49. }
  50. }
  51. public virtual LanguageOptions LanguageOptions {
  52. get {
  53. return LanguageOptions.None;
  54. }
  55. }
  56. //
  57. // Methods
  58. //
  59. public abstract ICodeCompiler CreateCompiler();
  60. public abstract ICodeGenerator CreateGenerator();
  61. public virtual ICodeGenerator CreateGenerator (string fileName)
  62. {
  63. return CreateGenerator();
  64. }
  65. public virtual ICodeGenerator CreateGenerator (TextWriter output)
  66. {
  67. return CreateGenerator();
  68. }
  69. public virtual ICodeParser CreateParser()
  70. {
  71. return null;
  72. }
  73. public virtual TypeConverter GetConverter (Type type)
  74. {
  75. return TypeDescriptor.GetConverter (type);
  76. }
  77. #if NET_2_0
  78. public virtual CompilerResults CompileAssemblyFromDom (CompilerParameters options, params CodeCompileUnit[] compilationUnits)
  79. {
  80. return CreateCompiler ().CompileAssemblyFromDomBatch (options, compilationUnits);
  81. }
  82. public static CodeDomProvider CreateProvider (string language)
  83. {
  84. return GetCompilerInfo (language).CreateProvider ();
  85. }
  86. public virtual void GenerateCodeFromCompileUnit (CodeCompileUnit compileUnit,
  87. TextWriter writer, CodeGeneratorOptions options)
  88. {
  89. CreateGenerator ().GenerateCodeFromCompileUnit (compileUnit, writer, options);
  90. }
  91. public virtual void GenerateCodeFromStatement (CodeStatement statement, TextWriter writer, CodeGeneratorOptions options)
  92. {
  93. CreateGenerator ().GenerateCodeFromStatement (statement, writer, options);
  94. }
  95. [MonoTODO ("Not implemented")]
  96. public static CompilerInfo GetCompilerInfo (string language)
  97. {
  98. return null;
  99. }
  100. public virtual bool Supports (GeneratorSupport supports)
  101. {
  102. return CreateGenerator ().Supports (supports);
  103. }
  104. #endif
  105. }
  106. }