/// <summary> /// Gets the content files. /// Content files are found in: /// < project > < ItemGroup > < Content > /// Then: /// get name from the atribute "Include", /// get CopyToOutputDirectory from child element "CopyToOutputDirectory" /// </summary> /// <param name="doc"></param> /// <param name="mgr"></param> /// <returns></returns> private List <ProjectContentFile> GetContent(XmlDocument doc, XmlNamespaceManager mgr) { XmlNodeList nodes; List <ProjectContentFile> files; XmlNode node; string filename; int index; ProjectContentFile file; files = new List <ProjectContentFile>(); nodes = doc.SelectNodes("/x:Project/x:ItemGroup/x:Content", mgr); foreach (XmlNode child in nodes) { file = new ProjectContentFile(); filename = child.Attributes["Include"].InnerText; index = -1; if (filename.Contains(Path.DirectorySeparatorChar.ToString())) { index = filename.LastIndexOf(Path.DirectorySeparatorChar); } file.Name = filename.Substring(index + 1); file.Location = filename.Substring(0, index + 1); node = child.SelectSingleNode("./x:CopyToOutputDirectory", mgr); if (node != null) { file.CopyToOutputDirectory = true; } files.Add(file); } return(files); }
/// <summary> /// Gets the content files. /// Content files are found in: /// < project > < ItemGroup > < Content > /// Then: /// get name from the atribute "Include", /// get CopyToOutputDirectory from child element "CopyToOutputDirectory" /// </summary> /// <param name = "doc"></param> /// <param name = "mgr"></param> /// <returns></returns> private List<ProjectContentFile> GetContent(XmlDocument doc, XmlNamespaceManager mgr) { XmlNodeList nodes; List<ProjectContentFile> files; XmlNode node; string filename; int index; ProjectContentFile file; files = new List<ProjectContentFile>(); nodes = doc.SelectNodes("/x:Project/x:ItemGroup/x:Content", mgr); foreach (XmlNode child in nodes) { file = new ProjectContentFile(); filename = child.Attributes["Include"].InnerText; index = -1; if (filename.Contains(Path.DirectorySeparatorChar.ToString())) { index = filename.LastIndexOf(Path.DirectorySeparatorChar); } file.Name = filename.Substring(index + 1); file.Location = filename.Substring(0, index + 1); node = child.SelectSingleNode("./x:CopyToOutputDirectory", mgr); if (node != null) { file.CopyToOutputDirectory = true; } files.Add(file); } return files; }