public Example() { WebServerSettings webSettings = (WebServerSettings)ConfigurationSettings.GetConfig("Xeon"); webroot = "http://localhost:" + webSettings.ServerPort + "/"; assLocations = webSettings.Servlets; }
public override void Initialize() { WebServerSettings settings = (WebServerSettings)ConfigurationSettings.GetConfig("Xeon"); contentLocation = settings.DynamicContent; base.Initialize(); }
/// <summary> /// Required method in the IConfigurationSectionHandler and creates a DebugSetting class /// per read node in the app.config. /// </summary> /// <param name="parent"></param> /// <param name="configContext"></param> /// <param name="section"></param> /// <returns></returns> public object Create(object parent, object configContext, System.Xml.XmlNode section) { WebServerSettings settings = null; try { XmlNode startUp = section.SelectSingleNode("StartUp"); XmlNode portNode = section.SelectSingleNode("ServerPort"); XmlNode staticContentNode = section.SelectSingleNode("StaticContent"); XmlNode dynamicContentNode = section.SelectSingleNode("DynamicContent"); XmlNode xmlDumpNode = section.SelectSingleNode("XmlDump"); XmlNode xmlDebugReloadNode = section.SelectSingleNode("XmlDebugReload"); XmlNode servletNode = section.SelectSingleNode("Servlets"); settings = new WebServerSettings(); if (startUp != null) { settings.StartUp = bool.Parse(startUp.Attributes["Value"].Value); } settings.ServerPort = int.Parse(portNode.Attributes["value"].Value); settings.StaticContent = staticContentNode.Attributes["location"].Value; settings.DynamicContent = dynamicContentNode.Attributes["location"].Value; if (servletNode != null) { if (servletNode.Attributes["assembly"] != null) { settings.Servlets = servletNode.Attributes["assembly"].Value.Split(','); for (int k = 0; k < settings.Servlets.Length; k++) { settings.Servlets[k] = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + settings.Servlets[k].Trim(); } } } settings.XmlDumpPath = xmlDumpNode.Attributes["location"].Value; settings.XmlDebugReload = bool.Parse(xmlDebugReloadNode.Attributes["value"].Value); } catch (Exception exc) { Trace.WriteLine("An error occured while reading the webserver configuration..." + exc.Message, "Warning"); } return(settings); }