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