ControlAdapter.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. //
  2. // System.Web.UI.Adapters.ControlAdapter
  3. //
  4. // Author:
  5. // Dick Porter <[email protected]>
  6. //
  7. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. #if NET_2_0
  29. using System.Web;
  30. using System.Web.UI;
  31. using System.ComponentModel;
  32. namespace System.Web.UI.Adapters
  33. {
  34. public abstract class ControlAdapter
  35. {
  36. internal ControlAdapter (Control c)
  37. {
  38. control = c;
  39. }
  40. protected ControlAdapter ()
  41. {
  42. }
  43. protected HttpBrowserCapabilities Browser
  44. {
  45. get {
  46. Page page = Page;
  47. if (page != null)
  48. return page.Request.Browser;
  49. return null;
  50. }
  51. }
  52. internal Control control;
  53. [Browsable (false)]
  54. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  55. protected Control Control
  56. {
  57. get { return control; }
  58. }
  59. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  60. [Browsable (false)]
  61. protected Page Page
  62. {
  63. get {
  64. Control control = Control;
  65. if (control != null)
  66. return control.Page;
  67. return null;
  68. }
  69. }
  70. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  71. [Browsable (false)]
  72. protected PageAdapter PageAdapter
  73. {
  74. get {
  75. Page page = Page;
  76. if (page != null)
  77. return page.PageAdapter;
  78. return null;
  79. }
  80. }
  81. protected internal virtual void BeginRender (HtmlTextWriter w)
  82. {
  83. w.BeginRender();
  84. }
  85. protected internal virtual void CreateChildControls ()
  86. {
  87. Control control = Control;
  88. if (control != null)
  89. control.CreateChildControls ();
  90. }
  91. protected internal virtual void EndRender (HtmlTextWriter w)
  92. {
  93. w.EndRender ();
  94. }
  95. protected internal virtual void LoadAdapterControlState (object state)
  96. {
  97. }
  98. protected internal virtual void LoadAdapterViewState (object state)
  99. {
  100. }
  101. protected internal virtual void OnInit (EventArgs e)
  102. {
  103. Control control = Control;
  104. if (control != null)
  105. control.OnInit(e);
  106. }
  107. protected internal virtual void OnLoad (EventArgs e)
  108. {
  109. Control control = Control;
  110. if (control != null)
  111. control.OnLoad(e);
  112. }
  113. protected internal virtual void OnPreRender (EventArgs e)
  114. {
  115. Control control = Control;
  116. if (control != null)
  117. control.OnPreRender(e);
  118. }
  119. protected internal virtual void OnUnload (EventArgs e)
  120. {
  121. Control control = Control;
  122. if (control != null)
  123. control.OnUnload(e);
  124. }
  125. protected internal virtual void Render (HtmlTextWriter w)
  126. {
  127. Control control = Control;
  128. if (control != null)
  129. control.Render (w);
  130. }
  131. protected internal virtual void RenderChildren (HtmlTextWriter w)
  132. {
  133. Control control = Control;
  134. if (control != null)
  135. control.RenderChildren (w);
  136. }
  137. protected internal virtual object SaveAdapterControlState ()
  138. {
  139. return null;
  140. }
  141. protected internal virtual object SaveAdapterViewState ()
  142. {
  143. return null;
  144. }
  145. }
  146. }
  147. #endif