Пример #1
0
        private bool ReadProject(XmlReader reader, string root)
        {
            string name = reader.GetAttribute("name");
            string typeString = reader.GetAttribute("type");
            string languageString = reader.GetAttribute("language");
            string location = reader.GetAttribute("location");

            List<string> projectDeps = new List<string>();
            List<DirSpec> dirSpecs = new List<DirSpec>();
            while (reader.Read()) {
                if (reader.NameIs("project") && !reader.IsStartElement())
                    break;
                else if (!reader.IsStartElement())
                    continue;

                if (reader.NameIs("dir")) {
                    dirSpecs.Add(new DirSpec() {
                        include = reader.GetAttribute("include"),
                        recurse = reader.GetAttribute("recurse") == "true",
                    });
                }
                else if (reader.NameIs("dep"))
                    projectDeps.Add(reader.GetAttribute("project"));
            }

            // Default to including the files in the project's directory
            if (dirSpecs.Count == 0)
                dirSpecs.Add(new DirSpec() { include = "." });

            var rootFilter = GatherProjectFiles(root, location, dirSpecs);

            ProjectType type;
            if (!EnumHelpers.TryParse<ProjectType>(typeString, out type))
                return false;

            Language language;
            if (languageString == "C++")
                language = Language.CPlusPlus;
            else
                throw new NotImplementedException("Only C++ projects are supported at this time.");

            ProjectRef projectRef;
            if (!m_projectRefs.TryGetValue(name, out projectRef)) {
                projectRef = new ProjectRef(name);
                m_projectRefs.Add(name, projectRef);
            }

            Project project = new Project(root, name, type, language, rootFilter);

            projectRef.SetProject(project);

            foreach (var dep in projectDeps) {
                if (!m_projectRefs.ContainsKey(dep))
                    m_projectRefs.Add(dep, new ProjectRef(dep));
            }

            return true;
        }