-//\r
-// System.Web.HttpContext\r
-//\r
-// Author:\r
-// Patrik Torstensson (Patrik.Torstensson@labs2.com)\r
-//\r
-using System;\r
-using System.Collections;\r
-using System.Security.Principal;\r
-using System.Web.Caching;\r
-using System.Web.Configuration;\r
-using System.Web.SessionState;\r
-using System.Threading;\r
-\r
-namespace System.Web {\r
- public sealed class HttpContext : IServiceProvider {\r
- private Exception [] _arrExceptions;\r
-\r
- private HttpResponse _oResponse;\r
- private HttpRequest _oRequest;\r
- private HttpServerUtility _Server;\r
- private HttpApplication _oApplication;\r
- private HttpWorkerRequest _oWorkerRequest;\r
- private IHttpHandler _Handler;\r
- private IHttpAsyncHandler _AsyncHandler;\r
- private IPrincipal _User;\r
- \r
- private bool _skipauth;\r
- private Hashtable _oItems;\r
- private DateTime _oTimestamp;\r
-\r
- public HttpContext(HttpRequest Request, HttpResponse Response) {\r
- Context = this;\r
-\r
- _arrExceptions = null;\r
- _oItems = null;\r
- _oTimestamp = DateTime.Now;\r
- _oRequest = Request;\r
- _oResponse = Response;\r
- }\r
-\r
- public HttpContext(HttpWorkerRequest WorkerRequest) {\r
- Context = this;\r
-\r
- _arrExceptions = null;\r
- _oItems = null;\r
- _oTimestamp = DateTime.Now;\r
- _oRequest = new HttpRequest(WorkerRequest, this);\r
- _oResponse = new HttpResponse(WorkerRequest, this);\r
- _oWorkerRequest = WorkerRequest;\r
- }\r
-\r
- internal HttpWorkerRequest WorkerRequest {\r
- get {\r
- return _oWorkerRequest;\r
- }\r
- }\r
- \r
- [MonoTODO("Context - Use System.Remoting.Messaging.CallContext instead of Thread storage")]\r
- internal static HttpContext Context {\r
- get {\r
- return (HttpContext) Thread.GetData(Thread.GetNamedDataSlot("Context"));\r
- }\r
-\r
- set {\r
- Thread.SetData(Thread.GetNamedDataSlot("Context"), value);\r
- }\r
- }\r
-\r
- public Exception [] AllErrors {\r
- get {\r
- return _arrExceptions;\r
- }\r
- }\r
-\r
- public HttpApplicationState Application {\r
- get {\r
- return HttpApplicationFactory.ApplicationState;\r
- }\r
- }\r
-\r
- public HttpApplication ApplicationInstance {\r
- get {\r
- return _oApplication;\r
- }\r
- set {\r
- _oApplication = value;\r
- }\r
- }\r
-\r
- public Cache Cache {\r
- get {\r
- return HttpRuntime.Cache;\r
- }\r
- }\r
-\r
- public static HttpContext Current {\r
- get {\r
- return Context;\r
- }\r
- }\r
-\r
- public Exception Error {\r
- get {\r
- if (_arrExceptions == null || _arrExceptions.Length == 0)\r
- return null;\r
- else\r
- return _arrExceptions[0];\r
- }\r
- }\r
-\r
- public IHttpHandler Handler {\r
- get { \r
- return _Handler;\r
- }\r
- \r
- set {\r
- _Handler = value;\r
- }\r
- }\r
-\r
- internal IHttpAsyncHandler AsyncHandler {\r
- get { \r
- return _AsyncHandler;\r
- }\r
- \r
- set {\r
- _AsyncHandler = value;\r
- }\r
- }\r
- \r
- [MonoTODO("bool IsCustomErrorEnabled")]\r
- public bool IsCustomErrorEnabled {\r
- get {\r
- throw new NotImplementedException();\r
- }\r
- }\r
-\r
- [MonoTODO("bool IsDebuggingEnabled")]\r
- public bool IsDebuggingEnabled {\r
- get {\r
- throw new NotImplementedException();\r
- }\r
- }\r
-\r
- public IDictionary Items {\r
- get {\r
- if (_oItems == null) {\r
- _oItems = new Hashtable();\r
- }\r
- \r
- return _oItems;\r
- }\r
- }\r
-\r
- public HttpRequest Request {\r
- get {\r
- return _oRequest;\r
- }\r
- }\r
-\r
- public HttpResponse Response {\r
- get {\r
- return _oResponse;\r
- }\r
- }\r
-\r
- public HttpServerUtility Server {\r
- get {\r
- if (null == _Server) {\r
- _Server = new HttpServerUtility(this);\r
- }\r
- \r
- return _Server; \r
- }\r
- }\r
- \r
- public HttpSessionState Session {\r
- get {\r
- return (HttpSessionState) Items["sessionstate"];\r
- }\r
- }\r
-\r
- public bool SkipAuthorization {\r
- get {\r
- return _skipauth;\r
- }\r
-\r
- set {\r
- _skipauth = value;\r
- }\r
- }\r
-\r
- public DateTime Timestamp {\r
- get {\r
- return _oTimestamp;\r
- }\r
- }\r
- \r
- [MonoTODO("TraceContext Trace")]\r
- public TraceContext Trace {\r
- get {\r
- throw new NotImplementedException();\r
- }\r
- }\r
- \r
- public IPrincipal User {\r
- get {\r
- return _User;\r
- }\r
- set {\r
- _User = value;\r
- }\r
- }\r
- \r
- public void AddError(Exception errorInfo) {\r
- int iSize;\r
-\r
- if (_arrExceptions == null) {\r
- iSize = 1;\r
- } \r
- else {\r
- iSize = _arrExceptions.Length + 1;\r
- }\r
-\r
- Exception [] arrNew = new Exception[iSize];\r
-\r
- if (null != _arrExceptions)\r
- _arrExceptions.CopyTo(arrNew, 0);\r
-\r
- _arrExceptions = arrNew;\r
- \r
- _arrExceptions[iSize - 1] = errorInfo;\r
- }\r
-\r
- public void ClearError() {\r
- _arrExceptions = null;\r
- }\r
-\r
- [MonoTODO("GetConfig(string name)")]\r
- public object GetConfig(string name) {\r
- throw new NotImplementedException();\r
- }\r
-\r
- [MonoTODO("GetAppConfig(string name)")]\r
- public static object GetAppConfig(string name) {\r
- if (null == name)\r
- throw new NotImplementedException();\r
-\r
- // This is a temp hack to fix the config stuff\r
- if (name.ToLower() == "system.web/httpmodules") {\r
- return new ModulesConfiguration();\r
- }\r
-\r
- if (name.ToLower() == "system.web/globalization") {\r
- return new System.Web.Configuration.GlobalizationConfiguration();\r
- }\r
- \r
- throw new NotImplementedException();\r
- }\r
- \r
- object IServiceProvider.GetService(Type service) {\r
- if (service == typeof(HttpWorkerRequest)) \r
- return _oWorkerRequest;\r
-\r
- if (service == typeof(HttpRequest))\r
- return Request;\r
-\r
- if (service == typeof(HttpResponse))\r
- return Response;\r
-\r
- if (service == typeof(HttpApplication))\r
- return ApplicationInstance;\r
-\r
- if (service == typeof(HttpApplicationState))\r
- return Application;\r
-\r
- if (service == typeof(HttpSessionState))\r
- return Session;\r
-\r
- if (service == typeof(HttpServerUtility))\r
- return Server;\r
-\r
- return null;\r
- }\r
-\r
- [MonoTODO("void RewritePath(string path)")]\r
- public void RewritePath(string Path) {\r
- throw new NotImplementedException();\r
- }\r
- }\r
-}\r
+//
+// System.Web.HttpContext
+//
+// Author:
+// Patrik Torstensson (Patrik.Torstensson@labs2.com)
+//
+using System;
+using System.Collections;
+using System.Security.Principal;
+using System.Web.Caching;
+using System.Web.Configuration;
+using System.Web.SessionState;
+using System.Threading;
+
+namespace System.Web
+{
+ public sealed class HttpContext : IServiceProvider
+ {
+ private Exception [] _arrExceptions;
+
+ private HttpResponse _oResponse;
+ private HttpRequest _oRequest;
+ private HttpServerUtility _Server;
+ private HttpApplication _oApplication;
+ private HttpWorkerRequest _oWorkerRequest;
+ private IHttpHandler _Handler;
+ private IHttpAsyncHandler _AsyncHandler;
+ private IPrincipal _User;
+
+ private bool _skipauth;
+ private Hashtable _oItems;
+ private DateTime _oTimestamp;
+
+ public HttpContext (HttpRequest Request, HttpResponse Response)
+ {
+ Context = this;
+
+ _arrExceptions = null;
+ _oItems = null;
+ _oTimestamp = DateTime.Now;
+ _oRequest = Request;
+ _oResponse = Response;
+ }
+
+ public HttpContext (HttpWorkerRequest WorkerRequest)
+ {
+ Context = this;
+
+ _arrExceptions = null;
+ _oItems = null;
+ _oTimestamp = DateTime.Now;
+ _oRequest = new HttpRequest (WorkerRequest, this);
+ _oResponse = new HttpResponse (WorkerRequest, this);
+ _oWorkerRequest = WorkerRequest;
+ }
+
+ internal HttpWorkerRequest WorkerRequest
+ {
+ get {
+ return _oWorkerRequest;
+ }
+ }
+
+ [MonoTODO("Context - Use System.Remoting.Messaging.CallContext instead of Thread storage")]
+ internal static HttpContext Context
+ {
+ get {
+ return (HttpContext) Thread.GetData (Thread.GetNamedDataSlot ("Context"));
+ }
+
+ set {
+ Thread.SetData (Thread.GetNamedDataSlot ("Context"), value);
+ }
+ }
+
+ public Exception [] AllErrors
+ {
+ get {
+ return _arrExceptions;
+ }
+ }
+
+ public HttpApplicationState Application
+ {
+ get {
+ return HttpApplicationFactory.ApplicationState;
+ }
+ }
+
+ public HttpApplication ApplicationInstance
+ {
+ get {
+ return _oApplication;
+ }
+ set {
+ _oApplication = value;
+ }
+ }
+
+ public Cache Cache
+ {
+ get {
+ return HttpRuntime.Cache;
+ }
+ }
+
+ public static HttpContext Current
+ {
+ get {
+ return Context;
+ }
+ }
+
+ public Exception Error
+ {
+ get {
+ if (_arrExceptions == null || _arrExceptions.Length == 0)
+ return null;
+
+ return _arrExceptions [0];
+ }
+ }
+
+ public IHttpHandler Handler
+ {
+ get {
+ return _Handler;
+ }
+
+ set {
+ _Handler = value;
+ }
+ }
+
+ internal IHttpAsyncHandler AsyncHandler
+ {
+ get {
+ return _AsyncHandler;
+ }
+
+ set {
+ _AsyncHandler = value;
+ }
+ }
+
+ [MonoTODO("bool IsCustomErrorEnabled")]
+ public bool IsCustomErrorEnabled
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ [MonoTODO("bool IsDebuggingEnabled")]
+ public bool IsDebuggingEnabled
+ {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public IDictionary Items
+ {
+ get {
+ if (_oItems == null)
+ _oItems = new Hashtable ();
+
+ return _oItems;
+ }
+ }
+
+ public HttpRequest Request
+ {
+ get {
+ return _oRequest;
+ }
+ }
+
+ public HttpResponse Response
+ {
+ get {
+ return _oResponse;
+ }
+ }
+
+ public HttpServerUtility Server
+ {
+ get {
+ if (null == _Server)
+ _Server = new HttpServerUtility (this);
+
+ return _Server;
+ }
+ }
+
+ public HttpSessionState Session
+ {
+ get {
+ return (HttpSessionState) Items ["sessionstate"];
+ }
+ }
+
+ public bool SkipAuthorization
+ {
+ get {
+ return _skipauth;
+ }
+
+ set {
+ _skipauth = value;
+ }
+ }
+
+ public DateTime Timestamp
+ {
+ get {
+ return _oTimestamp;
+ }
+ }
+
+ [MonoTODO("TraceContext Trace")]
+ public TraceContext Trace
+ {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ public IPrincipal User
+ {
+ get {
+ return _User;
+ }
+ set {
+ _User = value;
+ }
+ }
+
+ public void AddError (Exception errorInfo)
+ {
+ int iSize = 1;
+
+ if (_arrExceptions != null)
+ iSize += _arrExceptions.Length;
+
+ Exception [] arrNew = new Exception [iSize];
+
+ if (null != _arrExceptions)
+ _arrExceptions.CopyTo (arrNew, 0);
+
+ _arrExceptions = arrNew;
+
+ _arrExceptions [iSize - 1] = errorInfo;
+ }
+
+ public void ClearError ()
+ {
+ _arrExceptions = null;
+ }
+
+ [MonoTODO("GetConfig(string name)")]
+ public object GetConfig (string name)
+ {
+ throw new NotImplementedException();
+ }
+
+ [MonoTODO("GetAppConfig(string name)")]
+ public static object GetAppConfig (string name)
+ {
+ if (null == name)
+ throw new NotImplementedException();
+
+ // This is a temp hack to fix the config stuff
+ if (name.ToLower() == "system.web/httpmodules") {
+ return new ModulesConfiguration();
+ }
+
+ if (name.ToLower() == "system.web/globalization") {
+ return new System.Web.Configuration.GlobalizationConfiguration();
+ }
+
+ throw new NotImplementedException();
+ }
+
+ object IServiceProvider.GetService (Type service)
+ {
+ if (service == typeof (HttpWorkerRequest))
+ return _oWorkerRequest;
+
+ if (service == typeof (HttpRequest))
+ return Request;
+
+ if (service == typeof (HttpResponse))
+ return Response;
+
+ if (service == typeof (HttpApplication))
+ return ApplicationInstance;
+
+ if (service == typeof (HttpApplicationState))
+ return Application;
+
+ if (service == typeof (HttpSessionState))
+ return Session;
+
+ if (service == typeof (HttpServerUtility))
+ return Server;
+
+ return null;
+ }
+
+ [MonoTODO("void RewritePath(string path)")]
+ public void RewritePath (string Path)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+