UserControl.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. //
  2. // System.Web.UI.UserControl
  3. //
  4. // Authors:
  5. // Gonzalo Paniagua Javier ([email protected])
  6. //
  7. // (C) 2002 Ximian, Inc (http://www.ximian.com)
  8. //
  9. using System;
  10. using System.Web.Caching;
  11. using System.Web.SessionState;
  12. namespace System.Web.UI
  13. {
  14. public class UserControl : TemplateControl, IAttributeAccessor
  15. {
  16. private bool initialized;
  17. private AttributeCollection attributes;
  18. public UserControl ()
  19. {
  20. //??
  21. }
  22. public HttpApplicationState Application
  23. {
  24. get {
  25. Page p = Page;
  26. if (p == null)
  27. return null;
  28. return p.Application;
  29. }
  30. }
  31. public AttributeCollection Attributes
  32. {
  33. get {
  34. if (attributes == null)
  35. attributes = new AttributeCollection (new StateBag ());
  36. return attributes;
  37. }
  38. }
  39. public Cache Cache
  40. {
  41. get {
  42. Page p = Page;
  43. if (p == null)
  44. return null;
  45. return p.Cache;
  46. }
  47. }
  48. public bool IsPostBack
  49. {
  50. get {
  51. Page p = Page;
  52. if (p == null)
  53. return false;
  54. return p.IsPostBack;
  55. }
  56. }
  57. public HttpRequest Request
  58. {
  59. get {
  60. Page p = Page;
  61. if (p == null)
  62. return null;
  63. return p.Request;
  64. }
  65. }
  66. public HttpResponse Response
  67. {
  68. get {
  69. Page p = Page;
  70. if (p == null)
  71. return null;
  72. return p.Response;
  73. }
  74. }
  75. public HttpServerUtility Server
  76. {
  77. get {
  78. Page p = Page;
  79. if (p == null)
  80. return null;
  81. return p.Server;
  82. }
  83. }
  84. public HttpSessionState Session
  85. {
  86. get {
  87. Page p = Page;
  88. if (p == null)
  89. return null;
  90. return p.Session;
  91. }
  92. }
  93. public TraceContext Trace
  94. {
  95. get {
  96. Page p = Page;
  97. if (p == null)
  98. return null;
  99. return p.Trace;
  100. }
  101. }
  102. [MonoTODO]
  103. public void DesignerInitialize ()
  104. {
  105. throw new NotImplementedException ();
  106. }
  107. public void InitializeAsUserControl (Page page)
  108. {
  109. if (initialized)
  110. return;
  111. initialized = true;
  112. FrameworkInitialize ();
  113. }
  114. [MonoTODO]
  115. public string MapPath (string virtualPath)
  116. {
  117. throw new NotImplementedException ();
  118. }
  119. [MonoTODO]
  120. protected override void LoadViewState (object savedState)
  121. {
  122. throw new NotImplementedException ();
  123. }
  124. protected override void OnInit (EventArgs e)
  125. {
  126. if (Page != null)
  127. InitializeAsUserControl (Page);
  128. base.OnInit(e);
  129. }
  130. [MonoTODO]
  131. protected override object SaveViewState ()
  132. {
  133. throw new NotImplementedException ();
  134. }
  135. string IAttributeAccessor.GetAttribute (string name)
  136. {
  137. if (attributes == null)
  138. return null;
  139. return attributes [name];
  140. }
  141. void IAttributeAccessor.SetAttribute (string name, string value)
  142. {
  143. Attributes [name] = value;
  144. }
  145. }
  146. }