HttpContextWrapper.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. //
  2. // HttpContextWrapper.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2008 Novell Inc. http://novell.com
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System;
  30. using System.Collections;
  31. using System.Collections.Generic;
  32. using System.Globalization;
  33. using System.Runtime.CompilerServices;
  34. using System.Security.Permissions;
  35. using System.Security.Principal;
  36. using System.Web.Caching;
  37. using System.Web.Profile;
  38. namespace System.Web
  39. {
  40. #if NET_4_0
  41. [TypeForwardedFrom ("System.Web.Abstractions, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
  42. #endif
  43. [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  44. [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  45. public class HttpContextWrapper : HttpContextBase
  46. {
  47. HttpContext w;
  48. public HttpContextWrapper (HttpContext httpContext)
  49. {
  50. if (httpContext == null)
  51. throw new ArgumentNullException ("httpContext");
  52. w = httpContext;
  53. }
  54. public override Exception [] AllErrors {
  55. get { return w.AllErrors; }
  56. }
  57. public override HttpApplicationStateBase Application {
  58. get { return new HttpApplicationStateWrapper (w.Application); }
  59. }
  60. public override HttpApplication ApplicationInstance {
  61. get { return w.ApplicationInstance; }
  62. set { w.ApplicationInstance = value; }
  63. }
  64. public override Cache Cache {
  65. get { return w.Cache; }
  66. }
  67. public override IHttpHandler CurrentHandler {
  68. get { return w.CurrentHandler; }
  69. }
  70. public override RequestNotification CurrentNotification {
  71. get { return w.CurrentNotification; }
  72. }
  73. public override Exception Error {
  74. get { return w.Error; }
  75. }
  76. public override IHttpHandler Handler {
  77. get { return w.Handler; }
  78. set { w.Handler = value; }
  79. }
  80. public override bool IsCustomErrorEnabled {
  81. get { return w.IsCustomErrorEnabled; }
  82. }
  83. public override bool IsDebuggingEnabled {
  84. get { return w.IsDebuggingEnabled; }
  85. }
  86. public override bool IsPostNotification {
  87. get { return w.IsPostNotification; }
  88. }
  89. public override IDictionary Items {
  90. get { return w.Items; }
  91. }
  92. public override IHttpHandler PreviousHandler {
  93. get { return w.PreviousHandler; }
  94. }
  95. public override ProfileBase Profile {
  96. get { return w.Profile; }
  97. }
  98. public override HttpRequestBase Request {
  99. get { return new HttpRequestWrapper (w.Request); }
  100. }
  101. public override HttpResponseBase Response {
  102. get { return new HttpResponseWrapper (w.Response); }
  103. }
  104. public override HttpServerUtilityBase Server {
  105. get { return new HttpServerUtilityWrapper (w.Server); }
  106. }
  107. public override HttpSessionStateBase Session {
  108. get { return new HttpSessionStateWrapper (w.Session); }
  109. }
  110. public override bool SkipAuthorization {
  111. get { return w.SkipAuthorization; }
  112. set { w.SkipAuthorization = value; }
  113. }
  114. public override DateTime Timestamp {
  115. get { return w.Timestamp; }
  116. }
  117. public override TraceContext Trace {
  118. get { return w.Trace; }
  119. }
  120. public override IPrincipal User {
  121. get { return w.User; }
  122. set { w.User = value; }
  123. }
  124. public override void AddError (Exception errorInfo)
  125. {
  126. w.AddError (errorInfo);
  127. }
  128. public override void ClearError ()
  129. {
  130. w.ClearError ();
  131. }
  132. public override object GetGlobalResourceObject (string classKey, string resourceKey)
  133. {
  134. return HttpContext.GetGlobalResourceObject (classKey, resourceKey);
  135. }
  136. public override object GetGlobalResourceObject (string classKey, string resourceKey, CultureInfo culture)
  137. {
  138. return HttpContext.GetGlobalResourceObject (classKey, resourceKey, culture);
  139. }
  140. public override object GetLocalResourceObject (string overridePath, string resourceKey)
  141. {
  142. return HttpContext.GetLocalResourceObject (overridePath, resourceKey);
  143. }
  144. public override object GetLocalResourceObject (string overridePath, string resourceKey, CultureInfo culture)
  145. {
  146. return HttpContext.GetLocalResourceObject (overridePath, resourceKey, culture);
  147. }
  148. public override object GetSection (string sectionName)
  149. {
  150. return w.GetSection (sectionName);
  151. }
  152. [MonoTODO]
  153. public override object GetService (Type serviceType)
  154. {
  155. throw new NotImplementedException ();
  156. }
  157. public override void RewritePath (string path)
  158. {
  159. w.RewritePath (path);
  160. }
  161. public override void RewritePath (string path, bool rebaseClientPath)
  162. {
  163. w.RewritePath (path, rebaseClientPath);
  164. }
  165. public override void RewritePath (string filePath, string pathInfo, string queryString)
  166. {
  167. w.RewritePath (filePath, pathInfo, queryString);
  168. }
  169. public override void RewritePath (string filePath, string pathInfo, string queryString, bool setClientFilePath)
  170. {
  171. w.RewritePath (filePath, pathInfo, queryString, setClientFilePath);
  172. }
  173. }
  174. }