HostingEnvironment.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. //
  2. // System.Web.Hosting.HostingEnvironment.cs
  3. //
  4. // Author:
  5. // Chris Toshok ([email protected])
  6. // Gonzalo Paniagua Javier ([email protected])
  7. //
  8. //
  9. // Copyright (C) 2005,2006 Novell, Inc (http://www.novell.com)
  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. #if NET_2_0
  31. using System;
  32. using System.Security.Permissions;
  33. using System.Web.Caching;
  34. using System.Web.Util;
  35. namespace System.Web.Hosting {
  36. [AspNetHostingPermission (SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Medium)]
  37. [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.High)]
  38. public sealed class HostingEnvironment : MarshalByRefObject
  39. {
  40. static bool is_hosted;
  41. static string site_name;
  42. static ApplicationShutdownReason shutdown_reason;
  43. static VirtualPathProvider vpath_provider; // This should get a default
  44. public HostingEnvironment ()
  45. {
  46. }
  47. public static string ApplicationID {
  48. get { return HttpRuntime.AppDomainAppId; }
  49. }
  50. public static string ApplicationPhysicalPath {
  51. get { return HttpRuntime.AppDomainAppPath; }
  52. }
  53. public static string ApplicationVirtualPath {
  54. get { return HttpRuntime.AppDomainAppVirtualPath; }
  55. }
  56. public static Cache Cache {
  57. get { return HttpRuntime.Cache; }
  58. }
  59. public static Exception InitializationException {
  60. get { return HttpApplication.InitializationException; }
  61. }
  62. public static bool IsHosted {
  63. get { return is_hosted; }
  64. }
  65. public static ApplicationShutdownReason ShutdownReason {
  66. get { return shutdown_reason; }
  67. }
  68. [MonoTODO]
  69. public static string SiteName {
  70. get { return site_name; }
  71. }
  72. public static VirtualPathProvider VirtualPathProvider {
  73. get { return vpath_provider; }
  74. }
  75. [MonoTODO]
  76. public static void DecrementBusyCount ()
  77. {
  78. throw new NotImplementedException ();
  79. }
  80. [MonoTODO]
  81. public static IDisposable Impersonate ()
  82. {
  83. throw new NotImplementedException ();
  84. }
  85. [MonoTODO]
  86. public static IDisposable Impersonate (IntPtr token)
  87. {
  88. throw new NotImplementedException ();
  89. }
  90. [MonoTODO]
  91. public static IDisposable Impersonate (IntPtr userToken, string virtualPath)
  92. {
  93. throw new NotImplementedException ();
  94. }
  95. [MonoTODO]
  96. public static void IncrementBusyCount ()
  97. {
  98. throw new NotImplementedException ();
  99. }
  100. public override object InitializeLifetimeService ()
  101. {
  102. return null;
  103. }
  104. [MonoTODO]
  105. public static void InitiateShutdown ()
  106. {
  107. throw new NotImplementedException ();
  108. }
  109. public static string MapPath (string virtualPath)
  110. {
  111. if (virtualPath == null || virtualPath == "")
  112. throw new ArgumentNullException ("virtualPath");
  113. if (UrlUtils.IsRelativeUrl (virtualPath)) {
  114. string msg = String.Format ("The relative virtual path '{0}', is not allowed here.", virtualPath);
  115. throw new ArgumentException (msg);
  116. }
  117. HttpContext context = HttpContext.Current;
  118. if (context == null)
  119. return null;
  120. return context.Request.MapPath (virtualPath);
  121. }
  122. [MonoTODO]
  123. public static void RegisterObject (IRegisteredObject obj)
  124. {
  125. throw new NotImplementedException ();
  126. }
  127. public static void RegisterVirtualPathProvider (VirtualPathProvider virtualPathProvider)
  128. {
  129. if (HttpRuntime.AppDomainAppVirtualPath == null)
  130. throw new InvalidOperationException ();
  131. if (virtualPathProvider == null)
  132. throw new ArgumentNullException ("virtualPathProvider");
  133. virtualPathProvider.SetPrevious (vpath_provider);
  134. vpath_provider = virtualPathProvider;
  135. }
  136. [MonoTODO]
  137. public static IDisposable SetCultures (string virtualPath)
  138. {
  139. throw new NotImplementedException ();
  140. }
  141. [MonoTODO]
  142. public static IDisposable SetCultures ()
  143. {
  144. throw new NotImplementedException ();
  145. }
  146. [MonoTODO]
  147. public static void UnregisterObject (IRegisteredObject obj)
  148. {
  149. throw new NotImplementedException ();
  150. }
  151. }
  152. }
  153. #endif