예제 #1
0
파일: VCProject.cs 프로젝트: zhandb/slimdx
        static void ProcessElement(Counter counter, XElement element, Node rootNode)
        {
            foreach (XElement e in element.Elements("File"))
            {
                XAttribute attribute = e.Attribute("RelativePath");
                if (attribute == null)
                    continue;

                FileNode file = new FileNode();
                file.Path = Path.Combine(Path.GetDirectoryName(projectPath), attribute.Value);
                counter.CountFile(file);

                if (file.Valid)
                    rootNode.ChildNodes.Add(file);
            }

            foreach (XElement e in element.Elements("Filter"))
            {
                XAttribute attribute = e.Attribute("Name");
                if (attribute == null)
                    continue;

                Node node = new Node();
                node.Name = attribute.Value;
                ProcessElement(counter, e, node);

                rootNode.ChildNodes.Add(node);
            }
        }
예제 #2
0
        static void ProcessElement(Counter counter, XElement element, Node rootNode)
        {
            foreach (XElement e in element.Elements("File"))
            {
                XAttribute attribute = e.Attribute("RelativePath");
                if (attribute == null)
                {
                    continue;
                }

                FileNode file = new FileNode();
                file.Path = Path.Combine(Path.GetDirectoryName(projectPath), attribute.Value);
                counter.CountFile(file);

                if (file.Valid)
                {
                    rootNode.ChildNodes.Add(file);
                }
            }

            foreach (XElement e in element.Elements("Filter"))
            {
                XAttribute attribute = e.Attribute("Name");
                if (attribute == null)
                {
                    continue;
                }

                Node node = new Node();
                node.Name = attribute.Value;
                ProcessElement(counter, e, node);

                rootNode.ChildNodes.Add(node);
            }
        }
예제 #3
0
파일: CSProject.cs 프로젝트: zhandb/slimdx
        public static Node Process(Counter counter, string fileName)
        {
            Node rootNode = new Node();
            rootNode.Name = Path.GetFileNameWithoutExtension(fileName);

            XNamespace ns = "http://schemas.microsoft.com/developer/msbuild/2003";
            XDocument document;
            try
            {
                document = XDocument.Load(fileName);
            }
            catch (XmlException)
            {
                return null;
            }

            XElement projectElement = document.Element(ns + "Project");
            if (projectElement == null)
                return null;

            foreach (XElement e in projectElement.Elements(ns + "ItemGroup"))
            {
                foreach (XElement i in e.Elements(ns + "Compile"))
                {
                    string file = i.Attribute("Include").Value;
                    string path = Path.Combine(Path.GetDirectoryName(fileName), file);

                    Node currentNode = rootNode;

                    while (file.Contains('\\'))
                    {
                        int index = file.IndexOf('\\');
                        string directory = file.Substring(0, index);
                        file = file.Substring(index + 1);

                        bool found = false;
                        foreach (Node node in currentNode.ChildNodes)
                        {
                            if (node.Name == directory)
                            {
                                found = true;
                                currentNode = node;
                                break;
                            }
                        }

                        if (!found)
                        {
                            Node node = new Node();
                            node.Name = directory;
                            currentNode.ChildNodes.Add(node);
                            currentNode = node;
                        }
                    }

                    FileNode fileNode = new FileNode();
                    fileNode.Path = path;
                    counter.CountFile(fileNode);

                    if (fileNode.Valid)
                        currentNode.ChildNodes.Add(fileNode);
                }
            }

            return rootNode;
        }
예제 #4
0
        public static Node Process(Counter counter, string fileName)
        {
            Node rootNode = new Node();

            rootNode.Name = Path.GetFileNameWithoutExtension(fileName);

            XNamespace ns = "http://schemas.microsoft.com/developer/msbuild/2003";
            XDocument  document;

            try
            {
                document = XDocument.Load(fileName);
            }
            catch (XmlException)
            {
                return(null);
            }

            XElement projectElement = document.Element(ns + "Project");

            if (projectElement == null)
            {
                return(null);
            }

            foreach (XElement e in projectElement.Elements(ns + "ItemGroup"))
            {
                foreach (XElement i in e.Elements(ns + "Compile"))
                {
                    string file = i.Attribute("Include").Value;
                    string path = Path.Combine(Path.GetDirectoryName(fileName), file);

                    Node currentNode = rootNode;

                    while (file.Contains('\\'))
                    {
                        int    index     = file.IndexOf('\\');
                        string directory = file.Substring(0, index);
                        file = file.Substring(index + 1);

                        bool found = false;
                        foreach (Node node in currentNode.ChildNodes)
                        {
                            if (node.Name == directory)
                            {
                                found       = true;
                                currentNode = node;
                                break;
                            }
                        }

                        if (!found)
                        {
                            Node node = new Node();
                            node.Name = directory;
                            currentNode.ChildNodes.Add(node);
                            currentNode = node;
                        }
                    }

                    FileNode fileNode = new FileNode();
                    fileNode.Path = path;
                    counter.CountFile(fileNode);

                    if (fileNode.Valid)
                    {
                        currentNode.ChildNodes.Add(fileNode);
                    }
                }
            }

            return(rootNode);
        }