ApplicationFileParser.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // System.Web.UI.ApplicationFileParser.cs
  3. //
  4. // Authors:
  5. // Gonzalo Paniagua Javier ([email protected])
  6. //
  7. // (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
  8. // (c) 2004 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. using System;
  31. using System.Collections;
  32. using System.Web;
  33. using System.Web.Compilation;
  34. namespace System.Web.UI
  35. {
  36. sealed class ApplicationFileParser : TemplateParser
  37. {
  38. static ArrayList dependencies;
  39. public ApplicationFileParser (string fname, HttpContext context)
  40. {
  41. InputFile = fname;
  42. Context = context;
  43. }
  44. protected override Type CompileIntoType ()
  45. {
  46. return GlobalAsaxCompiler.CompileApplicationType (this);
  47. }
  48. internal static Type GetCompiledApplicationType (string inputFile, HttpContext context)
  49. {
  50. ApplicationFileParser parser = new ApplicationFileParser (inputFile, context);
  51. AspGenerator generator = new AspGenerator (parser);
  52. Type type = generator.GetCompiledType ();
  53. dependencies = parser.Dependencies;
  54. return type;
  55. }
  56. internal override void AddDirective (string directive, Hashtable atts)
  57. {
  58. if (String.Compare (directive, "application", true) != 0 &&
  59. String.Compare (directive, "Import", true) != 0 &&
  60. String.Compare (directive, "Assembly", true) != 0)
  61. ThrowParseException ("Invalid directive: " + directive);
  62. base.AddDirective (directive, atts);
  63. }
  64. internal static ArrayList FileDependencies {
  65. get { return dependencies; }
  66. }
  67. internal override Type DefaultBaseType {
  68. get { return typeof (HttpApplication); }
  69. }
  70. internal override string DefaultBaseTypeName {
  71. get { return "System.Web.HttpApplication"; }
  72. }
  73. internal override string DefaultDirectiveName {
  74. get { return "application"; }
  75. }
  76. internal override string BaseVirtualDir {
  77. get { return Context.Request.ApplicationPath; }
  78. }
  79. }
  80. }