Exemplo n.º 1
0
        static IISExpress()
        {
            IisExpressConfig = new IISExpressConfiguration();

            if (IisExpressConfig.CheckIISExpressConfigExistence())
            {
                _iisSites = IISConfigReader.ReadXmlFromConfig(IisExpressConfig);
                _iisSites = IISProcessManager.AssignProcessIds(_iisSites);
            }
        }
Exemplo n.º 2
0
        internal static List<IISSites> ReadXmlFromConfig(IISExpressConfiguration iisExConfig)
        {
            _iisSites = new List<IISSites>();

            if (!iisExConfig.CheckIISExpressConfigExistence()) return null;

            string contents = File.ReadAllText(iisExConfig.IISExpressConfigAddress);

            var document = new XmlDocument();
            document.LoadXml(contents);
            var siteList = document.GetElementsByTagName("site");
            var bindingNodes = document.SelectNodes("/configuration/system.applicationHost/sites/site/bindings");
            var counter = 0;
            foreach (object node in siteList)
            {
                var xmlElement = (XmlElement)node;
                var portNumber = FindPort(bindingNodes.Item(counter).InnerXml);
                var physicalPathElement = xmlElement.SelectSingleNode(".//virtualDirectory/@physicalPath");
                var physicalPath = physicalPathElement == null ? "" : physicalPathElement.InnerText;

                _iisSites.Add(new IISSites(xmlElement.Attributes["name"].Value, xmlElement.Attributes["id"].Value, portNumber, physicalPath));
                counter++;
            }

            return _iisSites;
        }