Exemplo n.º 1
0
        public static List <WebAppConfig> GetApplicationsFromConfigFile(string fileName)
        {
            List <WebAppConfig> applist = new List <WebAppConfig> ();

            try {
                XmlDocument doc = new XmlDocument();
                doc.Load(fileName);

                foreach (XmlElement el in doc.SelectNodes("//web-application"))
                {
                    WebAppConfig appConfig = (WebAppConfig)GetConfigFromElement(typeof(WebAppConfig), el);
                    appConfig.RealPath = Path.GetFullPath(appConfig.RealPath);
                    applist.Add(appConfig);
                }
            } catch {
                Console.WriteLine("Error loading '{0}'", fileName);
                throw;
            }

            return(applist);
        }
		private IApplicationHost CreateAppHost(Type appHostType, object appHostConfig, 
			WebAppConfig appConfig, 
			IListenerTransport listenerTransport, Type appHostTransportType, object appHostTransportConfig)
		{
			try
			{
				IApplicationHost host = hostFactory.CreateApplicationHost (appHostType, appConfig.VHost, appConfig.VPort, appConfig.VPath, appConfig.RealPath);
				host.Configure (appHostConfig, appConfig, this, listenerTransport, appHostTransportType, appHostTransportConfig);
				//subscribe to Unload event only after run host.Configure
				//because apphost transport must unregister himself first
				host.HostUnload += OnHostUnload;

				lock (hosts) {
					hosts.Add (new HostInfo () {
						Host = host,
						AppHostType = appHostType,
						AppHostConfig = appHostConfig,
						AppConfig = appConfig,
						ListenerTransport = listenerTransport,
						AppHostTransportType = appHostTransportType,
						AppHostTransportConfig = appHostTransportConfig
					});
				}
				return host;
			} catch (Exception ex) {
				Logger.Write (LogLevel.Error, "Can't create host {0}", ex);
				return null;
			}

		}