GlobalAsaxCompiler.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // System.Web.Compilation.GlobalAsaxCompiler
  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. using System;
  11. using System.Collections;
  12. using System.Web.UI;
  13. namespace System.Web.Compilation
  14. {
  15. class GlobalAsaxCompiler : BaseCompiler
  16. {
  17. ApplicationFileParser parser;
  18. static ArrayList applicationObjectTags = new ArrayList (1);
  19. static ArrayList sessionObjectTags = new ArrayList (1);
  20. static ArrayList imports;
  21. static ArrayList assemblies;
  22. public GlobalAsaxCompiler (ApplicationFileParser parser)
  23. : base (parser)
  24. {
  25. applicationObjectTags.Clear ();
  26. sessionObjectTags.Clear ();
  27. if (imports != null)
  28. imports.Clear ();
  29. if (assemblies != null)
  30. assemblies.Clear ();
  31. this.parser = parser;
  32. }
  33. public static Type CompileApplicationType (ApplicationFileParser parser)
  34. {
  35. AspGenerator generator = new AspGenerator (parser);
  36. Type type = generator.GetCompiledType ();
  37. imports = parser.Imports;
  38. assemblies = parser.Assemblies;
  39. return type;
  40. }
  41. protected override void CreateMethods ()
  42. {
  43. base.CreateMethods ();
  44. ProcessObjects (parser.RootBuilder);
  45. }
  46. void ProcessObjects (ControlBuilder builder)
  47. {
  48. if (builder.Children == null)
  49. return;
  50. foreach (object t in builder.Children) {
  51. if (!(t is ObjectTagBuilder))
  52. continue;
  53. ObjectTagBuilder tag = (ObjectTagBuilder) t;
  54. if (tag.Scope == null) {
  55. string fname = CreateFieldForObject (tag.Type, tag.ObjectID);
  56. CreatePropertyForObject (tag.Type, tag.ObjectID, fname, true);
  57. continue;
  58. }
  59. if (tag.Scope == "session") {
  60. sessionObjectTags.Add (tag);
  61. CreateApplicationOrSessionPropertyForObject (tag.Type, tag.ObjectID,
  62. false, false);
  63. } else if (tag.Scope == "application") {
  64. applicationObjectTags.Add (tag);
  65. CreateFieldForObject (tag.Type, tag.ObjectID);
  66. CreateApplicationOrSessionPropertyForObject (tag.Type, tag.ObjectID,
  67. true, false);
  68. } else {
  69. throw new ParseException (tag.location, "Invalid scope: " + tag.Scope);
  70. }
  71. }
  72. }
  73. internal static ArrayList ApplicationObjects {
  74. get { return applicationObjectTags; }
  75. }
  76. internal static ArrayList SessionObjects {
  77. get { return sessionObjectTags; }
  78. }
  79. internal static ArrayList Assemblies {
  80. get { return assemblies; }
  81. }
  82. internal static ArrayList Imports {
  83. get { return imports; }
  84. }
  85. }
  86. }