GlobalAsaxCompiler.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. public GlobalAsaxCompiler (ApplicationFileParser parser)
  21. : base (parser)
  22. {
  23. applicationObjectTags.Clear ();
  24. sessionObjectTags.Clear ();
  25. this.parser = parser;
  26. }
  27. public static Type CompileApplicationType (ApplicationFileParser parser)
  28. {
  29. AspGenerator generator = new AspGenerator (parser);
  30. return generator.GetCompiledType ();
  31. }
  32. protected override void CreateMethods ()
  33. {
  34. base.CreateMethods ();
  35. ProcessObjects (parser.RootBuilder);
  36. }
  37. void ProcessObjects (ControlBuilder builder)
  38. {
  39. if (builder.Children == null)
  40. return;
  41. foreach (object t in builder.Children) {
  42. if (!(t is ObjectTagBuilder))
  43. continue;
  44. ObjectTagBuilder tag = (ObjectTagBuilder) t;
  45. if (tag.Scope == null) {
  46. string fname = CreateFieldForObject (tag.Type, tag.ObjectID);
  47. CreatePropertyForObject (tag.Type, tag.ObjectID, fname, true);
  48. continue;
  49. }
  50. if (tag.Scope == "session") {
  51. sessionObjectTags.Add (tag);
  52. CreateApplicationOrSessionPropertyForObject (tag.Type, tag.ObjectID,
  53. false, false);
  54. } else if (tag.Scope == "application") {
  55. applicationObjectTags.Add (tag);
  56. CreateFieldForObject (tag.Type, tag.ObjectID);
  57. CreateApplicationOrSessionPropertyForObject (tag.Type, tag.ObjectID,
  58. true, false);
  59. } else {
  60. throw new ParseException (tag.location, "Invalid scope: " + tag.Scope);
  61. }
  62. }
  63. }
  64. internal static ArrayList ApplicationObjects {
  65. get { return applicationObjectTags; }
  66. }
  67. internal static ArrayList SessionObjects {
  68. get { return sessionObjectTags; }
  69. }
  70. }
  71. }