示例#1
0
        public static ObservableCollection<WebSite> GetAllWebsites(IFileIO fileIO)
        {
            if (fileIO == null)
            {
                throw new ArgumentNullException("fileIO");
            }

            IEnumerable<XElement> xdoc = null;
            try
            {
                xdoc = fileIO.GetSitesSection();
            }
            catch (Exception ex)
            {
                throw new ApplicationException(
                    String.Format("Error access IIS Express applicationhost config file: {0}", ex.Message));
            }
            if (xdoc == null)
            {
                return null;
            }

            try
            {
                return new ObservableCollection<WebSite>(
                    from site in xdoc.Descendants("site")
                    select new WebSite(
                        Convert.ToInt32(site.Attribute("id").Value),
                        site.Attribute("name").Value,
                        site.Attribute("serverAutoStart") == null ? true : Convert.ToBoolean(site.Attribute("serverAutoStart").Value),
                        site.Element("application").Attribute("path").Value,
                        site.Element("application").Attribute("applicationPool") == null ? string.Empty : site.Element("application").Attribute("applicationPool").Value,
                        site.Element("application").Element("virtualDirectory").Attribute("path").Value,
                        site.Element("application").Element("virtualDirectory").Attribute("physicalPath").Value,
                        (BindingProtocol)Enum.Parse(typeof(BindingProtocol), site.Element("bindings").Element("binding").Attribute("protocol").Value),
                        site.Element("bindings").Element("binding").Attribute("bindingInformation").Value,
                        fileIO.Exists(site.Element("application").Element("virtualDirectory").Attribute("physicalPath").Value)));
            }
            catch (Exception ex)
            {
                throw new ApplicationException(
                    String.Format("Error parsing applicationhost config file: {0}", ex.Message));
            }
        }
示例#2
0
 public static WebSite Create(IFileIO fileIO, int id, string name, bool serverAutoStart,
     string applicationPath, string applicationPool, string virtualPath, string physicalPath,
     BindingProtocol protocol, string bindingInfo)
 {
     var dirIsValid = false;
     try
     {
         dirIsValid = fileIO.Exists(physicalPath);
         var newSite = new WebSite(id, name, serverAutoStart, applicationPath, applicationPool, virtualPath,
             physicalPath, protocol, bindingInfo, dirIsValid);
         newSite.Save(fileIO);
         return newSite;
     }
     catch (Exception ex)
     {
         throw new ApplicationException(string.Format("Error creating new website: {0}", ex));
     }
 }
示例#3
0
 public bool SolutionExists()
 {
     return(m_FileIOProvider.Exists(SolutionFile()));
 }
示例#4
0
 public bool HasSolutionBeenGenerated()
 {
     return(m_FileIOProvider.Exists(SolutionFile()));
 }
示例#5
0
 public bool ProjectExists(Compilation.Assembly assembly)
 {
     return(m_fileIOProvider.Exists(ProjectFile(assembly)));
 }