您的位置:首页 > 其它

生命周期

2015-11-09 12:08 281 查看
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;

namespace System.Web.Hosting
{
[SecurityPermission(SecurityAction.LinkDemand, Unrestricted = true)]
public sealed class AppManagerAppDomainFactory : IAppManagerAppDomainFactory
{
// Fields
//定义ApplicationManager
private ApplicationManager _appManager;

// Methods
public AppManagerAppDomainFactory()
{
this._appManager = ApplicationManager.GetApplicationManager();
this._appManager.Open();
}
internal static string ConstructSimpleAppName(string virtPath)
{
if (virtPath.Length <= 1)
{
return "root";
}
return virtPath.Substring(1).ToLower(CultureInfo.InvariantCulture).Replace('/', '_');
}
[return: MarshalAs(UnmanagedType.Interface)]
public object Create(string appId, string appPath)
{
object obj2;
try
{
if (appPath[0] == '.')
{
FileInfo info = new FileInfo(appPath);
appPath = info.FullName;
}
if (!StringUtil.StringEndsWith(appPath, '\\'))
{
appPath = appPath + @"\";
}
ISAPIApplicationHost appHost = new ISAPIApplicationHost(appId, appPath, false);
ISAPIRuntime o = (ISAPIRuntime)this._appManager.CreateObjectInternal(appId, typeof(ISAPIRuntime), appHost, false, null);
o.StartProcessing();
obj2 = new ObjectHandle(o);
}
catch (Exception)
{
throw;
}
return obj2;
}
public void Stop()
{
this._appManager.Close();
}
}
}


View Code
AppManagerAppDomainFactory中的构造函数已经写出来了,同样也实现了create和stop方法
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: