CompilerInfo.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // System.CodeDom.Compiler CompilerInfo class
  3. //
  4. // Author:
  5. // Marek Safar ([email protected])
  6. // Gonzalo Paniagua Javier ([email protected])
  7. //
  8. // Copyright (c) 2004,2005 Novell, Inc. (http://www.novell.com)
  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. #if NET_2_0
  31. using System.Security.Permissions;
  32. namespace System.CodeDom.Compiler {
  33. [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
  34. public sealed class CompilerInfo {
  35. internal string Languages;
  36. internal string Extensions;
  37. internal string TypeName;
  38. internal int WarningLevel;
  39. internal string CompilerOptions;
  40. bool inited;
  41. Type type;
  42. internal CompilerInfo ()
  43. {
  44. }
  45. void Init ()
  46. {
  47. if (inited)
  48. return;
  49. inited = true;
  50. type = Type.GetType (TypeName);
  51. if (type == null)
  52. return;
  53. if (!typeof (CodeDomProvider).IsAssignableFrom (type))
  54. type = null;
  55. }
  56. public Type CodeDomProviderType {
  57. get { return type; }
  58. }
  59. public bool IsCodeDomProviderTypeValid {
  60. get { return type != null; }
  61. }
  62. [MonoTODO]
  63. public CompilerParameters CreateDefaultCompilerParameters ()
  64. {
  65. throw new NotImplementedException ();
  66. }
  67. public CodeDomProvider CreateProvider ()
  68. {
  69. return (CodeDomProvider) Activator.CreateInstance (type);
  70. }
  71. public override bool Equals (object o)
  72. {
  73. if (!(o is CompilerInfo))
  74. return false;
  75. CompilerInfo c = (CompilerInfo) o;
  76. return c.TypeName == TypeName;
  77. }
  78. public override int GetHashCode ()
  79. {
  80. return TypeName.GetHashCode ();
  81. }
  82. public string [] GetExtensions ()
  83. {
  84. return Extensions.Split (';');
  85. }
  86. public string [] GetLanguages ()
  87. {
  88. return Languages.Split (';');
  89. }
  90. }
  91. }
  92. #endif