Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
//
// System.Web.Hosting.AppDomainFactory.cs
//
// Author:
// Miguel de Icaza (miguel@novell.com)
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Security.Permissions;
namespace System.Web.Hosting {
// CAS - no InheritanceDemand here as the class is sealed
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class AppDomainFactory : IAppDomainFactory {
#if NET_2_0
[AspNetHostingPermission (SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
#endif
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
public AppDomainFactory ()
{
}
[MonoTODO ("Not implemented")]
public object Create (string module, string typeName, string appId, string appPath, string strUrlOfAppOrigin, int iZone)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,52 @@
//
// System.Web.Hosting.AppManagerAppDomainFactory
//
// Author:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
//
//
// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
namespace System.Web.Hosting {
public sealed class AppManagerAppDomainFactory : IAppManagerAppDomainFactory {
public AppManagerAppDomainFactory ()
{
}
[MonoTODO ("Not implemented")]
public object Create (string appId, string appPath)
{
throw new NotImplementedException ();
}
public void Stop ()
{
// Stop all the stuff that we Create'd here
}
}
}
#endif

View File

@@ -0,0 +1,265 @@
//
// System.Web.Hosting.ApplicationHost.cs
//
// Author:
// Miguel de Icaza (miguel@novell.com)
//
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Configuration;
using System.IO;
using System.Security.Permissions;
using System.Security.Policy;
using System.Text;
using System.Web.Configuration;
namespace System.Web.Hosting {
// CAS - no InheritanceDemand here as the class is sealed
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class ApplicationHost {
const string DEFAULT_WEB_CONFIG_NAME = "web.config";
internal const string MonoHostedDataKey = ".:!MonoAspNetHostedApp!:.";
static object create_dir = new object ();
ApplicationHost ()
{
}
internal static string FindWebConfig (string basedir)
{
if (String.IsNullOrEmpty (basedir) || !Directory.Exists (basedir))
return null;
string[] files = Directory.GetFileSystemEntries (basedir, "?eb.?onfig");
if (files == null || files.Length == 0)
return null;
return files [0];
}
internal static bool ClearDynamicBaseDirectory (string directory)
{
string[] entries = null;
try {
entries = Directory.GetDirectories (directory);
} catch {
// ignore
}
bool dirEmpty = true;
if (entries != null && entries.Length > 0) {
foreach (string e in entries) {
if (ClearDynamicBaseDirectory (e)) {
try {
Directory.Delete (e);
} catch {
dirEmpty = false;
}
}
}
}
try {
entries = Directory.GetFiles (directory);
} catch {
entries = null;
}
if (entries != null && entries.Length > 0) {
foreach (string e in entries) {
try {
File.Delete (e);
} catch {
dirEmpty = false;
}
}
}
return dirEmpty;
}
static bool CreateDirectory (string directory)
{
lock (create_dir) {
if (!Directory.Exists (directory)) {
Directory.CreateDirectory (directory);
return false;
} else
return true;
}
}
static string BuildPrivateBinPath (string physicalPath, string[] dirs)
{
int len = dirs.Length;
string[] ret = new string [len];
for (int i = 0; i < len; i++)
ret [i] = Path.Combine (physicalPath, dirs [i]);
return String.Join (";", ret);
}
//
// For further details see `Hosting the ASP.NET runtime'
//
// http://www.west-wind.com/presentations/aspnetruntime/aspnetruntime.asp
//
#if TARGET_JVM
[MonoNotSupported ("")]
#endif
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
public static object CreateApplicationHost (Type hostType, string virtualDir, string physicalDir)
{
if (physicalDir == null)
throw new NullReferenceException ();
// Make sure physicalDir has file system semantics
// and not uri semantics ( '\' and not '/' ).
physicalDir = Path.GetFullPath (physicalDir);
if (hostType == null)
throw new ArgumentException ("hostType can't be null");
if (virtualDir == null)
throw new ArgumentNullException ("virtualDir");
Evidence evidence = new Evidence (AppDomain.CurrentDomain.Evidence);
//
// Setup
//
AppDomainSetup setup = new AppDomainSetup ();
setup.ApplicationBase = physicalDir;
string webConfig = FindWebConfig (physicalDir);
if (webConfig == null)
webConfig = Path.Combine (physicalDir, DEFAULT_WEB_CONFIG_NAME);
setup.ConfigurationFile = webConfig;
setup.DisallowCodeDownload = true;
string[] bindirPath = new string [1] { Path.Combine (physicalDir, "bin") };
string bindir;
foreach (string dir in HttpApplication.BinDirs) {
bindir = Path.Combine (physicalDir, dir);
if (Directory.Exists (bindir)) {
bindirPath [0] = bindir;
break;
}
}
setup.PrivateBinPath = BuildPrivateBinPath (physicalDir, bindirPath);
setup.PrivateBinPathProbe = "*";
string dynamic_dir = null;
string user = Environment.UserName;
int tempDirTag = 0;
string dirPrefix = String.Concat (user, "-temp-aspnet-");
for (int i = 0; ; i++){
string d = Path.Combine (Path.GetTempPath (), String.Concat (dirPrefix, i.ToString ("x")));
try {
CreateDirectory (d);
string stamp = Path.Combine (d, "stamp");
CreateDirectory (stamp);
dynamic_dir = d;
try {
Directory.Delete (stamp);
} catch (Exception) {
// ignore
}
tempDirTag = i.GetHashCode ();
break;
} catch (UnauthorizedAccessException){
continue;
}
}
//
// Unique Domain ID
//
string domain_id = (virtualDir.GetHashCode () + 1 ^ physicalDir.GetHashCode () + 2 ^ tempDirTag).ToString ("x");
// This is used by mod_mono's fail-over support
string domain_id_suffix = Environment.GetEnvironmentVariable ("__MONO_DOMAIN_ID_SUFFIX");
if (domain_id_suffix != null && domain_id_suffix.Length > 0)
domain_id += domain_id_suffix;
setup.ApplicationName = domain_id;
setup.DynamicBase = dynamic_dir;
setup.CachePath = dynamic_dir;
string dynamic_base = setup.DynamicBase;
if (CreateDirectory (dynamic_base) && (Environment.GetEnvironmentVariable ("MONO_ASPNET_NODELETE") == null))
ClearDynamicBaseDirectory (dynamic_base);
//
// Create app domain
//
AppDomain appdomain;
appdomain = AppDomain.CreateDomain (domain_id, evidence, setup);
//
// Populate with the AppDomain data keys expected, Mono only uses a
// few, but third party apps might use others:
//
appdomain.SetData (".appDomain", "*");
int l = physicalDir.Length;
if (physicalDir [l - 1] != Path.DirectorySeparatorChar)
physicalDir += Path.DirectorySeparatorChar;
appdomain.SetData (".appPath", physicalDir);
appdomain.SetData (".appVPath", virtualDir);
appdomain.SetData (".appId", domain_id);
appdomain.SetData (".domainId", domain_id);
appdomain.SetData (".hostingVirtualPath", virtualDir);
appdomain.SetData (".hostingInstallDir", Path.GetDirectoryName (typeof (Object).Assembly.CodeBase));
appdomain.SetData ("DataDirectory", Path.Combine (physicalDir, "App_Data"));
appdomain.SetData (MonoHostedDataKey, "yes");
appdomain.DoCallBack (SetHostingEnvironment);
return appdomain.CreateInstanceAndUnwrap (hostType.Module.Assembly.FullName, hostType.FullName);
}
static void SetHostingEnvironment ()
{
bool shadow_copy_enabled = true;
HostingEnvironmentSection he = WebConfigurationManager.GetWebApplicationSection ("system.web/hostingEnvironment") as HostingEnvironmentSection;
if (he != null)
shadow_copy_enabled = he.ShadowCopyBinAssemblies;
if (shadow_copy_enabled) {
AppDomain current = AppDomain.CurrentDomain;
current.SetShadowCopyFiles ();
current.SetShadowCopyPath (current.SetupInformation.PrivateBinPath);
}
HostingEnvironment.IsHosted = true;
HostingEnvironment.SiteName = HostingEnvironment.ApplicationID;
}
}
}

View File

@@ -0,0 +1,61 @@
//
// System.Web.Hosting.ApplicationInfo
//
// Author:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
//
//
// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
namespace System.Web.Hosting {
[Serializable]
public sealed class ApplicationInfo {
string id;
string physical_path;
string virtual_path;
internal ApplicationInfo (string id, string phys, string virt)
{
this.id = id;
this.physical_path = phys;
this.virtual_path = virt;
}
public string ID {
get { return id; }
}
public string PhysicalPath {
get { return physical_path; }
}
public string VirtualPath {
get { return virtual_path; }
}
}
}
#endif

View File

@@ -0,0 +1,256 @@
//
// System.Web.Hosting.ApplicationManager
//
// Author:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
//
//
// Copyright (C) 2006-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Permissions;
using System.Security.Policy;
using System.Threading;
namespace System.Web.Hosting {
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class ApplicationManager : MarshalByRefObject {
static ApplicationManager instance = new ApplicationManager ();
int users;
Dictionary <string, BareApplicationHost> id_to_host;
ApplicationManager ()
{
id_to_host = new Dictionary<string, BareApplicationHost> ();
}
public void Close ()
{
if (Interlocked.Decrement (ref users) == 0)
ShutdownAll ();
}
[MonoTODO ("Need to take advantage of the configuration mapping capabilities of IApplicationHost")]
[SecurityPermissionAttribute(SecurityAction.Demand, Unrestricted = true)]
public IRegisteredObject CreateObject (IApplicationHost appHost, Type type)
{
if (appHost == null)
throw new ArgumentNullException ("appHost");
if (type == null)
throw new ArgumentNullException ("type");
return CreateObject (appHost.GetSiteID (),
type,
appHost.GetVirtualPath (),
appHost.GetPhysicalPath (),
true,
true);
}
public IRegisteredObject CreateObject (string appId, Type type, string virtualPath,
string physicalPath, bool failIfExists)
{
return CreateObject (appId, type, virtualPath, physicalPath, failIfExists, true);
}
public IRegisteredObject CreateObject (string appId, Type type, string virtualPath,
string physicalPath, bool failIfExists, bool throwOnError)
{
if (appId == null)
throw new ArgumentNullException ("appId");
if (!VirtualPathUtility.IsAbsolute (virtualPath))
throw new ArgumentException ("Relative path no allowed.", "virtualPath");
if (String.IsNullOrEmpty (physicalPath))
throw new ArgumentException ("Cannot be null or empty", "physicalPath");
// 'type' is not checked. If it's null, we'll throw a NullReferenceException
if (!typeof (IRegisteredObject).IsAssignableFrom (type))
throw new ArgumentException (String.Concat ("Type '", type.Name, "' does not implement IRegisteredObject."), "type");
//
// ArgumentException is thrown for the physical path from the internal object created
// in the new application domain.
BareApplicationHost host = null;
if (id_to_host.ContainsKey (appId))
host = id_to_host [appId];
IRegisteredObject ireg = null;
if (host != null) {
ireg = CheckIfExists (host, type, failIfExists);
if (ireg != null)
return ireg;
}
try {
if (host == null)
host = CreateHost (appId, virtualPath, physicalPath);
ireg = host.CreateInstance (type);
} catch (Exception) {
if (throwOnError)
throw;
}
if (ireg != null && host.GetObject (type) == null) // If not registered from ctor...
host.RegisterObject (ireg, true);
return ireg;
}
// Used from ClientBuildManager
internal BareApplicationHost CreateHostWithCheck (string appId, string vpath, string ppath)
{
if (id_to_host.ContainsKey (appId))
throw new InvalidOperationException ("Already have a host with the same appId");
return CreateHost (appId, vpath, ppath);
}
BareApplicationHost CreateHost (string appId, string vpath, string ppath)
{
BareApplicationHost host;
host = (BareApplicationHost) ApplicationHost.CreateApplicationHost (typeof (BareApplicationHost), vpath, ppath);
host.Manager = this;
host.AppID = appId;
id_to_host [appId] = host;
return host;
}
internal void RemoveHost (string appId)
{
id_to_host.Remove (appId);
}
IRegisteredObject CheckIfExists (BareApplicationHost host, Type type, bool failIfExists)
{
IRegisteredObject ireg = host.GetObject (type);
if (ireg == null)
return null;
if (failIfExists)
throw new InvalidOperationException (String.Concat ("Well known object of type '", type.Name, "' already exists in this domain."));
return ireg;
}
public static ApplicationManager GetApplicationManager ()
{
return instance;
}
public IRegisteredObject GetObject (string appId, Type type)
{
if (appId == null)
throw new ArgumentNullException ("appId");
if (type == null)
throw new ArgumentNullException ("type");
BareApplicationHost host = null;
if (!id_to_host.ContainsKey (appId))
return null;
host = id_to_host [appId];
return host.GetObject (type);
}
public ApplicationInfo [] GetRunningApplications ()
{
ICollection<string> coll = id_to_host.Keys;
string [] keys = new string [coll.Count];
coll.CopyTo (keys, 0);
ApplicationInfo [] result = new ApplicationInfo [coll.Count];
int i = 0;
foreach (string str in keys) {
BareApplicationHost host = id_to_host [str];
result [i++] = new ApplicationInfo (str, host.PhysicalPath, host.VirtualPath);
}
return result;
}
public override object InitializeLifetimeService ()
{
return null;
}
public bool IsIdle ()
{
throw new NotImplementedException ();
}
public void Open ()
{
Interlocked.Increment (ref users);
}
public void ShutdownAll ()
{
ICollection<string> coll = id_to_host.Keys;
string [] keys = new string [coll.Count];
coll.CopyTo (keys, 0);
foreach (string str in keys) {
BareApplicationHost host = id_to_host [str];
host.Shutdown ();
}
id_to_host.Clear ();
}
public void ShutdownApplication (string appId)
{
if (appId == null)
throw new ArgumentNullException ("appId");
BareApplicationHost host = id_to_host [appId];
if (host == null)
return;
host.Shutdown ();
}
public void StopObject (string appId, Type type)
{
if (appId == null)
throw new ArgumentNullException ("appId");
if (type == null)
throw new ArgumentNullException ("type");
if (!id_to_host.ContainsKey (appId))
return;
BareApplicationHost host = id_to_host [appId];
if (host == null)
return;
host.StopObject (type);
}
}
}
#endif

View File

@@ -0,0 +1,141 @@
//
// System.Web.Hosting.BareApplicationHost
//
// Author:
// Gonzalo Paniagua Javier (gonzalo@novell.com)
//
//
// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.IO;
using System.Collections.Generic;
namespace System.Web.Hosting {
class RegisteredItem {
public IRegisteredObject Item;
public bool AutoClean;
public RegisteredItem (IRegisteredObject item, bool autoclean)
{
this.Item = item;
this.AutoClean = autoclean;
}
}
sealed class BareApplicationHost : MarshalByRefObject {
string vpath;
string phys_path;
Dictionary<Type, RegisteredItem> hash;
internal ApplicationManager Manager;
internal string AppID;
public BareApplicationHost ()
{
Init ();
}
void Init ()
{
hash = new Dictionary<Type, RegisteredItem> ();
HostingEnvironment.Host = this;
AppDomain current = AppDomain.CurrentDomain;
current.DomainUnload += OnDomainUnload;
phys_path = (string) current.GetData (".appPath");
vpath = (string) current.GetData (".appVPath");
}
public string VirtualPath {
get { return vpath; }
}
public string PhysicalPath {
get { return phys_path; }
}
public AppDomain Domain {
get { return AppDomain.CurrentDomain; }
}
public void Shutdown ()
{
HostingEnvironment.InitiateShutdown ();
}
public void StopObject (Type type)
{
if (!hash.ContainsKey (type))
return;
RegisteredItem reg = hash [type];
reg.Item.Stop (false);
}
public IRegisteredObject CreateInstance (Type type)
{
return (IRegisteredObject) Activator.CreateInstance (type, null);
}
public void RegisterObject (IRegisteredObject obj, bool auto_clean)
{
hash [obj.GetType ()] = new RegisteredItem (obj, auto_clean);
}
public bool UnregisterObject (IRegisteredObject obj)
{
return hash.Remove (obj.GetType ());
}
public IRegisteredObject GetObject (Type type)
{
if (hash.ContainsKey (type))
return hash [type].Item;
return null;
}
public string GetCodeGenDir ()
{
return AppDomain.CurrentDomain.SetupInformation.DynamicBase;
}
void OnDomainUnload (object sender, EventArgs args)
{
Manager.RemoveHost (AppID);
ICollection<RegisteredItem> values = hash.Values;
RegisteredItem [] objects = new RegisteredItem [hash.Count];
values.CopyTo (objects, 0);
foreach (RegisteredItem reg in objects) {
try {
reg.Item.Stop (true); // Stop should call Unregister. It's ok if not.
} catch {
// Ignore or throw?
}
}
hash.Clear ();
}
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,110 @@
//
// System.Web.Hosting.DefaultVirtualDirectory
//
// Author:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
//
// Copyright (c) 2006-2011 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
namespace System.Web.Hosting {
sealed class DefaultVirtualDirectory : VirtualDirectory
{
string phys_dir;
string virtual_dir;
internal DefaultVirtualDirectory (string virtualPath)
: base (virtualPath)
{
}
void Init ()
{
if (phys_dir == null) {
string vpath = VirtualPath;
string path = HostingEnvironment.MapPath (vpath);
if (File.Exists (path)) {
virtual_dir = VirtualPathUtility.GetDirectory (vpath);
phys_dir = HostingEnvironment.MapPath (virtual_dir);
} else {
virtual_dir = VirtualPathUtility.AppendTrailingSlash (vpath);
phys_dir = path;
}
}
}
List <VirtualFileBase> AddDirectories (List <VirtualFileBase> list, string dir)
{
if (String.IsNullOrEmpty (dir) || !Directory.Exists (dir))
return list;
foreach (string name in Directory.GetDirectories (phys_dir))
list.Add (new DefaultVirtualDirectory (VirtualPathUtility.Combine (virtual_dir, Path.GetFileName (name))));
return list;
}
List <VirtualFileBase> AddFiles (List <VirtualFileBase> list, string dir)
{
if (String.IsNullOrEmpty (dir) || !Directory.Exists (dir))
return list;
foreach (string name in Directory.GetFiles (phys_dir))
list.Add (new DefaultVirtualFile (VirtualPathUtility.Combine (virtual_dir, Path.GetFileName (name))));
return list;
}
public override IEnumerable Children {
get {
Init ();
var list = new List <VirtualFileBase> ();
AddDirectories (list, phys_dir);
return AddFiles (list, phys_dir);
}
}
public override IEnumerable Directories {
get {
Init ();
return AddDirectories (new List <VirtualFileBase> (), phys_dir);
}
}
public override IEnumerable Files {
get {
Init ();
return AddFiles (new List <VirtualFileBase> (), phys_dir);
}
}
}
}

View File

@@ -0,0 +1,52 @@
//
// System.Web.Hosting.DefaultVirtualFile
//
// Author:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
//
// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.IO;
namespace System.Web.Hosting {
class DefaultVirtualFile : VirtualFile
{
internal DefaultVirtualFile (string virtualPath)
: base (virtualPath)
{
}
public override Stream Open ()
{
return File.OpenRead (HostingEnvironment.MapPath (VirtualPath));
}
}
}
#endif

View File

@@ -0,0 +1,115 @@
//
// System.Web.Hosting.DefaultVirtualPathProvider
//
// Author:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
//
// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.IO;
using System.Web.Caching;
using System.Web.Util;
namespace System.Web.Hosting {
sealed class DefaultVirtualPathProvider : VirtualPathProvider {
internal DefaultVirtualPathProvider ()
{
}
protected override void Initialize ()
{
}
/*
* No need to override this, it seems
public override string CombineVirtualPaths (string basePath, string relativePath)
{
return VirtualPathUtility.Combine (basePath, relativePath);
}
*/
public override bool DirectoryExists (string virtualDir)
{
if (String.IsNullOrEmpty (virtualDir))
throw new ArgumentNullException ("virtualDir");
string phys_path = HostingEnvironment.MapPath (virtualDir);
return Directory.Exists (phys_path);
}
public override bool FileExists (string virtualPath)
{
if (String.IsNullOrEmpty (virtualPath))
throw new ArgumentNullException ("virtualPath");
string phys_path = HostingEnvironment.MapPath (virtualPath);
return File.Exists (phys_path);
}
public override CacheDependency GetCacheDependency (string virtualPath,
IEnumerable virtualPathDependencies,
DateTime utcStart)
{
return null;
}
public override string GetCacheKey (string virtualPath)
{
return null; // Always
}
public override VirtualDirectory GetDirectory (string virtualDir)
{
if (String.IsNullOrEmpty (virtualDir))
throw new ArgumentNullException ("virtualDir");
return new DefaultVirtualDirectory (virtualDir);
}
public override VirtualFile GetFile (string virtualPath)
{
if (String.IsNullOrEmpty (virtualPath))
throw new ArgumentNullException ("virtualPath");
return new DefaultVirtualFile (virtualPath);
}
public override string GetFileHash (string virtualPath, IEnumerable virtualPathDependencies)
{
if (virtualPath == null || virtualPathDependencies == null)
throw new NullReferenceException ();
// No deps -> 1505
// Non-existing virtual deps -> 1505
// Relative virtual deps -> exception
// virtualPath does not matter at all (?)
// The number varies accross xsp executions
return virtualPath;
}
}
}

View File

@@ -0,0 +1,208 @@
//
// System.Web.Hosting.HostingEnvironment.cs
//
// Author:
// Chris Toshok (toshok@ximian.com)
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
//
// Copyright (C) 2005,2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Globalization;
using System.Security.Permissions;
using System.Threading;
using System.Web.Configuration;
using System.Web.Caching;
using System.Web.Util;
namespace System.Web.Hosting {
[AspNetHostingPermission (SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Medium)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.High)]
public sealed class HostingEnvironment : MarshalByRefObject
{
static bool is_hosted;
#pragma warning disable 0649
static string site_name;
static ApplicationShutdownReason shutdown_reason;
#pragma warning restore 0649
internal static BareApplicationHost Host;
static VirtualPathProvider vpath_provider = (HttpRuntime.AppDomainAppVirtualPath == null) ? null :
new DefaultVirtualPathProvider ();
static int busy_count;
internal static bool HaveCustomVPP {
get;
private set;
}
public HostingEnvironment ()
{
// The documentation says that this is called once per domain by the ApplicationManager and
// then it throws InvalidOperationException whenever called.
throw new InvalidOperationException ();
}
public static string ApplicationID {
get { return HttpRuntime.AppDomainAppId; }
}
public static string ApplicationPhysicalPath {
get { return HttpRuntime.AppDomainAppPath; }
}
public static string ApplicationVirtualPath {
get { return HttpRuntime.AppDomainAppVirtualPath; }
}
public static Cache Cache {
get { return HttpRuntime.Cache; }
}
public static Exception InitializationException {
get { return HttpApplication.InitializationException; }
}
public static bool IsHosted {
get { return is_hosted; }
internal set { is_hosted = value; }
}
public static ApplicationShutdownReason ShutdownReason {
get { return shutdown_reason; }
}
public static string SiteName {
get { return site_name; }
internal set { site_name = value; }
}
public static VirtualPathProvider VirtualPathProvider {
get { return vpath_provider; }
}
public static void DecrementBusyCount ()
{
Interlocked.Decrement (ref busy_count);
}
[MonoTODO ("Not implemented")]
public static IDisposable Impersonate ()
{
throw new NotImplementedException ();
}
[MonoTODO ("Not implemented")]
public static IDisposable Impersonate (IntPtr token)
{
throw new NotImplementedException ();
}
[MonoTODO ("Not implemented")]
public static IDisposable Impersonate (IntPtr userToken, string virtualPath)
{
throw new NotImplementedException ();
}
public static void IncrementBusyCount ()
{
Interlocked.Increment (ref busy_count);
}
public override object InitializeLifetimeService ()
{
return null;
}
public static void InitiateShutdown ()
{
HttpRuntime.UnloadAppDomain ();
}
public static string MapPath (string virtualPath)
{
if (virtualPath == null || virtualPath == "")
throw new ArgumentNullException ("virtualPath");
HttpContext context = HttpContext.Current;
HttpRequest req = context == null ? null : context.Request;
if (req == null)
return null;
return req.MapPath (virtualPath);
}
public static void RegisterObject (IRegisteredObject obj)
{
if (obj == null)
throw new ArgumentNullException ("obj");
Host.RegisterObject (obj, false);
}
public static void RegisterVirtualPathProvider (VirtualPathProvider virtualPathProvider)
{
if (HttpRuntime.AppDomainAppVirtualPath == null)
throw new InvalidOperationException ();
if (virtualPathProvider == null)
throw new ArgumentNullException ("virtualPathProvider");
VirtualPathProvider previous = vpath_provider;
vpath_provider = virtualPathProvider;
vpath_provider.InitializeAndSetPrevious (previous);
if (!(virtualPathProvider is DefaultVirtualPathProvider))
HaveCustomVPP = true;
else
HaveCustomVPP = false;
}
public static IDisposable SetCultures (string virtualPath)
{
GlobalizationSection gs = WebConfigurationManager.GetSection ("system.web/globalization", virtualPath) as GlobalizationSection;
IDisposable ret = Thread.CurrentThread.CurrentCulture as IDisposable;
string culture = gs.Culture;
if (String.IsNullOrEmpty (culture))
return ret;
Thread.CurrentThread.CurrentCulture = new CultureInfo (culture);
return ret;
}
public static IDisposable SetCultures ()
{
return SetCultures ("~/");
}
public static void UnregisterObject (IRegisteredObject obj)
{
if (obj == null)
throw new ArgumentNullException ("obj");
Host.UnregisterObject (obj);
}
}
}
#endif

View File

@@ -0,0 +1,50 @@
//
// System.Web.Hosting.IAppDomainFactory.cs
//
// Author:
// Bob Smith <bob@thestuff.net>
//
// (C) Bob Smith
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
namespace System.Web.Hosting
{
[Guid ("e6e21054-a7dc-4378-877d-b7f4a2d7e8ba")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
[ComImportAttribute]
public interface IAppDomainFactory
{
[return: MarshalAs (UnmanagedType.Interface)]
object Create ([In, MarshalAs(UnmanagedType.BStr)] string module,
[In, MarshalAs(UnmanagedType.BStr)] string typeName,
[In, MarshalAs(UnmanagedType.BStr)] string appId,
[In, MarshalAs(UnmanagedType.BStr)] string appPath,
[In, MarshalAs(UnmanagedType.BStr)] string strUrlOfAppOrigin,
[In, MarshalAs(UnmanagedType.I4)] int iZone);
}
}

View File

@@ -0,0 +1,46 @@
//
// System.Web.Hosting.IAppManagerAppDomainFactory.cs
//
// Authors:
// Duncan Mak (duncan@ximian.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
#if NET_2_0
using System.Runtime.InteropServices;
namespace System.Web.Hosting
{
[GuidAttribute ("02998279-7175-4D59-AA5A-FB8E44D4CA9D")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
[ComImportAttribute]
public interface IAppManagerAppDomainFactory
{
[return: MarshalAs (UnmanagedType.Interface)]
object Create ([In, MarshalAs(UnmanagedType.BStr)] string s,
[In, MarshalAs(UnmanagedType.BStr)] string app_id);
void Stop ();
}
}
#endif

View File

@@ -0,0 +1,50 @@
//
// System.Web.IConfigMapPath
//
// Authors:
// Marek Habersack (mhabersack@novell.com)
//
// (C) 2009 Novell, Inc
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Security.Permissions;
using System.Web.Configuration;
namespace System.Web.Hosting
{
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public interface IApplicationHost
{
IConfigMapPathFactory GetConfigMapPathFactory ();
IntPtr GetConfigToken ();
string GetPhysicalPath ();
string GetSiteID ();
string GetSiteName ();
string GetVirtualPath ();
void MessageReceived ();
}
}
#endif

View File

@@ -0,0 +1,48 @@
//
// System.Web.Hosting.IISAPIRuntime.cs
//
// Author:
// Bob Smith <bob@thestuff.net>
//
// (C) Bob Smith
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
namespace System.Web.Hosting
{
//[Guid ("c4918956-485b-3503-bd10-9083e3f6b66c")] -> 1.1 pre service pack
[Guid ("08A2C56F-7C16-41C1-A8BE-432917A1A2D1")]
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
[ComImportAttribute]
public interface IISAPIRuntime
{
void DoGCCollect ();
[return: MarshalAs (UnmanagedType.I4)]
int ProcessRequest ([In] IntPtr ecb, [In, MarshalAs(UnmanagedType.I4)] int useProcessModel);
void StartProcessing ();
void StopProcessing ();
}
}

View File

@@ -0,0 +1,40 @@
//
// System.Web.Hosting.IRegisteredObject.cs
//
// Authors:
// Duncan Mak (duncan@ximian.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
using System;
using System.Runtime.InteropServices;
#if NET_2_0
namespace System.Web.Hosting
{
public interface IRegisteredObject
{
void Stop (bool immediate);
}
}
#endif

View File

@@ -0,0 +1,92 @@
//
// System.Web.Hosting.ISAPIRuntime.cs
//
// Author:
// Bob Smith <bob@thestuff.net>
// Gonzalo Paniagua (gonzalo@ximian.com)
//
// (C) Bob Smith
// (c) 2002 Ximian, Inc. (http://www.ximian.com)
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Security.Permissions;
namespace System.Web.Hosting {
#if NET_2_0
public sealed class ISAPIRuntime : MarshalByRefObject, IISAPIRuntime, IRegisteredObject {
#else
// CAS - no InheritanceDemand here as the class is sealed
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class ISAPIRuntime : IISAPIRuntime {
#endif
#if NET_2_0
[AspNetHostingPermission (SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
#endif
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
public ISAPIRuntime ()
{
}
public void DoGCCollect ()
{
// Do nothing.
}
[MonoTODO ("Not implemented")]
public int ProcessRequest (IntPtr ecb, int iWRType)
{
throw new NotImplementedException ();
}
[MonoTODO ("Not implemented")]
public void StartProcessing ()
{
throw new NotImplementedException ();
}
[MonoTODO ("Not implemented")]
#if NET_2_0
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
#endif
public void StopProcessing ()
{
throw new NotImplementedException ();
}
#if NET_2_0
[MonoTODO ("Not implemented")]
public override object InitializeLifetimeService ()
{
throw new NotImplementedException ();
}
[MonoTODO ("Not implemented")]
void IRegisteredObject.Stop (bool immediate)
{
throw new NotImplementedException ();
}
#endif
}
}

View File

@@ -0,0 +1,298 @@
//
// System.Web.Hosting.SimpleWorkerRequest.cs
//
// Author:
// Miguel de Icaza (miguel@novell.com)
// Gonzalo Paniagua Javier (gonzalo@novell.com)
//
//
// Copyright (C) 2005,2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.Util;
namespace System.Web.Hosting {
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[ComVisible (false)]
public class SimpleWorkerRequest : HttpWorkerRequest {
string page;
string query;
string app_virtual_dir;
string app_physical_dir;
string path_info;
TextWriter output;
bool hosted;
// computed
string raw_url;
//
// Constructor used when the target application domain
// was created with ApplicationHost.CreateApplicationHost
//
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
public SimpleWorkerRequest (string page, string query, TextWriter output)
{
this.page = page;
this.query = query;
this.output = output;
app_virtual_dir = HttpRuntime.AppDomainAppVirtualPath;
app_physical_dir = HttpRuntime.AppDomainAppPath;
hosted = true;
InitializePaths ();
}
//
// Creates a SimpleWorkerRequest that can be used from any AppDomain
//
// This is used for user instantiates HttpContext (my_SimpleWorkerRequest)
//
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
public SimpleWorkerRequest (string appVirtualDir, string appPhysicalDir, string page, string query, TextWriter output)
{
this.page = page;
this.query = query;
this.output = output;
app_virtual_dir = appVirtualDir;
app_physical_dir = appPhysicalDir;
InitializePaths ();
}
void InitializePaths ()
{
int idx = page.IndexOf ('/');
if (idx >= 0) {
path_info = page.Substring (idx);
page = page.Substring (0, idx);
} else {
path_info = "";
}
}
public override string MachineConfigPath {
get {
if (hosted) {
string path = ICalls.GetMachineConfigPath ();
if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) {
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand ();
}
return path;
}
return null;
}
}
public override string MachineInstallDirectory {
get {
if (hosted) {
string path = ICalls.GetMachineInstallDirectory ();
if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) {
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand ();
}
return path;
}
return null;
}
}
#if NET_2_0
public override string RootWebConfigPath {
get { return WebConfigurationManager.OpenWebConfiguration ("~").FilePath; }
}
#endif
public override void EndOfRequest ()
{
}
public override void FlushResponse (bool finalFlush)
{
}
public override string GetAppPath ()
{
return app_virtual_dir;
}
public override string GetAppPathTranslated ()
{
if (SecurityManager.SecurityEnabled && (app_physical_dir != null) && (app_physical_dir.Length > 0)) {
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, app_physical_dir).Demand ();
}
return app_physical_dir;
}
public override string GetFilePath ()
{
string result = UrlUtils.Combine (app_virtual_dir, page);
if (result == "")
return app_virtual_dir == "/" ? app_virtual_dir : app_virtual_dir + "/";
return result;
}
public override string GetFilePathTranslated ()
{
string local_page;
if (Path.DirectorySeparatorChar == '\\')
local_page = page.Replace ('/', '\\');
else
local_page = page;
string path = Path.Combine (app_physical_dir, local_page);
if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) {
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand ();
}
return path;
}
public override string GetHttpVerbName ()
{
return "GET";
}
public override string GetHttpVersion ()
{
return "HTTP/1.0";
}
public override string GetLocalAddress ()
{
return "127.0.0.1";
}
public override int GetLocalPort ()
{
return 80;
}
public override string GetPathInfo ()
{
return path_info;
}
public override string GetQueryString ()
{
return query;
}
public override string GetRawUrl ()
{
if (raw_url == null){
string q = ((query == null || query == "") ? "" : "?" + query);
raw_url = UrlUtils.Combine (app_virtual_dir, page);
if (path_info != "") {
raw_url += "/" + path_info + q;
} else {
raw_url += q;
}
}
return raw_url;
}
public override string GetRemoteAddress ()
{
return "127.0.0.1";
}
public override int GetRemotePort ()
{
return 0;
}
public override string GetServerVariable (string name)
{
return "";
}
public override string GetUriPath ()
{
if (app_virtual_dir == "/")
return app_virtual_dir + page + path_info;
return app_virtual_dir + "/" + page + path_info;
}
public override IntPtr GetUserToken ()
{
return IntPtr.Zero;
}
public override string MapPath (string path)
{
if (!hosted)
return null;
if (path != null && path.Length == 0)
return app_physical_dir;
if (!path.StartsWith (app_virtual_dir))
throw new ArgumentNullException ("path is not rooted in the virtual directory");
string rest = path.Substring (app_virtual_dir.Length);
if (rest.Length > 0 && rest [0] == '/')
rest = rest.Substring (1);
if (Path.DirectorySeparatorChar != '/') // for windows suport
rest = rest.Replace ('/', Path.DirectorySeparatorChar);
return Path.Combine (app_physical_dir, rest);
}
public override void SendKnownResponseHeader (int index, string value)
{
}
public override void SendResponseFromFile (IntPtr handle, long offset, long length)
{
}
public override void SendResponseFromFile (string filename, long offset, long length)
{
}
public override void SendResponseFromMemory (byte [] data, int length)
{
output.Write (System.Text.Encoding.Default.GetChars (data, 0, length));
}
public override void SendStatus (int statusCode, string statusDescription)
{
}
public override void SendUnknownResponseHeader (string name, string value)
{
}
}
}

View File

@@ -0,0 +1,57 @@
//
// System.Web.Hosting.VirtualDirectory
//
// Author:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
//
// Copyright (c) 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Collections;
namespace System.Web.Hosting {
public abstract class VirtualDirectory : VirtualFileBase
{
protected VirtualDirectory (string virtualPath)
{
SetVirtualPath (virtualPath);
}
public abstract IEnumerable Children { get; }
public abstract IEnumerable Directories { get; }
public abstract IEnumerable Files { get; }
public override bool IsDirectory {
get { return true; }
}
}
}
#endif

View File

@@ -0,0 +1,53 @@
//
// System.Web.Hosting.VirtualFile
//
// Author:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
//
// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.IO;
namespace System.Web.Hosting {
public abstract class VirtualFile : VirtualFileBase
{
protected VirtualFile (string virtualPath)
{
SetVirtualPath (virtualPath);
}
public override bool IsDirectory {
get { return false; }
}
public abstract Stream Open ();
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More