This should probably derived from ProjectContentFile but as I do not know how the structure of these classes will evolve as I'll add more project-readers, I believe it is safer to keep them as independent classes.
        /// <summary>
        ///     Gets the config files.
        ///     Config files are found in:
        ///     &lt; project &gt; &lt; ItemGroup &gt; &lt; None &gt;
        ///     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 <ProjectConfigFile> GetConfigs(XmlDocument doc, XmlNamespaceManager mgr)
        {
            XmlNodeList nodes;
            XmlNode     node;
            List <ProjectConfigFile> files;
            ProjectConfigFile        file;
            string filename;
            int    index;

            files = new List <ProjectConfigFile>();
            nodes = doc.SelectNodes("/x:Project/x:ItemGroup/x:None", mgr);
            foreach (XmlNode child in nodes)
            {
                file     = new ProjectConfigFile();
                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);
        }
示例#2
0
 /// <summary>
 ///   Gets the config files.
 ///   Config files are found in:
 ///   &lt; project &gt; &lt; ItemGroup &gt; &lt; None &gt;
 ///   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<ProjectConfigFile> GetConfigs(XmlDocument doc, XmlNamespaceManager mgr)
 {
     XmlNodeList nodes;
     XmlNode node;
     List<ProjectConfigFile> files;
     ProjectConfigFile file;
     string filename;
     int index;
     files = new List<ProjectConfigFile>();
     nodes = doc.SelectNodes("/x:Project/x:ItemGroup/x:None", mgr);
     foreach (XmlNode child in nodes)
     {
         file = new ProjectConfigFile();
         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;
 }