public static IEnumerable <SitePackage> Packages(this ISite site) { string configContent = site.GetWebConfigContent(); if (configContent == null) { return(null); } IList <SitePackage> packages = new List <SitePackage>(); string frameworkVersion = configContent.NetFrameworkVersionFromXml(); if (frameworkVersion != null) { packages.Add(new SitePackage { Name = "NetFrameworkVersion", NewVersion = frameworkVersion, SiteId = site.Id }); } XmlDocument doc = new XmlDocument(); doc.LoadXml(configContent); XmlNamespaceManager nsm = new XmlNamespaceManager(doc.NameTable); nsm.AddNamespace("ns", "urn:schemas-microsoft-com:asm.v1"); XmlNodeList nodes = null; nodes = doc.SelectNodes("//configuration/runtime/ns:assemblyBinding/ns:dependentAssembly", nsm); if (nodes.Count < 1) { return(packages); } XmlNodeList name = nodes[0].SelectNodes("//ns:assemblyIdentity/@name", nsm); string[] names = new string[name.Count]; // 11 for (int j = 0; j < name.Count; j++) // 11 j -0 { names[j] = name[j].InnerText; } XmlNodeList version = nodes[0].SelectNodes("//ns:bindingRedirect/@newVersion", nsm); // 11 for (int j = 0; j < version.Count; j++) { packages.Add(new SitePackage { Name = names[j], NewVersion = version[j].InnerText, SiteId = site.Id }); } return(packages); }
public IEnumerable <SiteWebConfiguration> Get(ISite site) { string configContent = site.GetWebConfigContent(); if (configContent == null) { return(null); } return(new[] { new SiteWebConfiguration { Id = site.Id, ContentRaw = configContent } }); }