Пример #1
0
        private void FillControlsWithModel(Model.CodeLiteWorkspace workspaceModel)
        {
            // Configurations combo
            this.comboBoxConfigurations.Items.Clear();
            this.comboBoxConfigurations.Items.Add("<Global>");

            foreach (var config in workspaceModel.Configurations)
            {
                this.comboBoxConfigurations.Items.Add(config.Name);
            }

            this.comboBoxConfigurations.SelectedIndex = 0;

            // Projects tree
            TreeNode root = new TreeNode(workspaceModel.Name);

            this.treeViewProjectHierarchy.Nodes.Clear();
            this.treeViewProjectHierarchy.Nodes.Add(root);

            foreach (var project in workspaceModel.Projects)
            {
                root.Nodes.Add(new TreeNode(project.Name));
            }
        }
        public CodeLiteWorkspace ParseWorkspace(string workspacePath)
        {
            // WORKSPACE
            XmlDocument workspaceReader = new XmlDocument();
            workspaceReader.Load(workspacePath);

            CodeLiteWorkspace workspace = new CodeLiteWorkspace();
            workspace.Name = workspaceReader.SelectSingleNode("CodeLite_Workspace").Attributes.GetNamedItem("Name").Value;

            // Configurations
            XmlNode buildMatrixNode = workspaceReader.SelectSingleNode("CodeLite_Workspace/BuildMatrix");
            workspace.Configurations = new List<WorkspaceConfiguration>();

            foreach (XmlNode configurationNode in buildMatrixNode.SelectNodes("WorkspaceConfiguration"))
            {
                WorkspaceConfiguration workspaceConfig = new WorkspaceConfiguration();
                workspace.Configurations.Add(workspaceConfig);
                workspaceConfig.Name = configurationNode.Attributes.GetNamedItem("Name").Value;

                workspaceConfig.Projects = new List<WorkspaceConfigurationProject>();

                foreach (XmlNode projectInConfigNode in configurationNode.SelectNodes("Project"))
                {
                    WorkspaceConfigurationProject projectConfiguration = new WorkspaceConfigurationProject();
                    workspaceConfig.Projects.Add(projectConfiguration);
                    projectConfiguration.Name = projectInConfigNode.Attributes.GetNamedItem("Name").Value;
                    projectConfiguration.ConfigName = projectInConfigNode.Attributes.GetNamedItem("ConfigName").Value;
                }
            }

            // PROJECTS
            workspace.Projects = new List<CodeLiteProject>();

            foreach (XmlNode projectNode in workspaceReader.SelectNodes("CodeLite_Workspace/Project"))
            {
                CodeLiteProject project = new CodeLiteProject();
                workspace.Projects.Add(project);
                project.Name = projectNode.Attributes.GetNamedItem("Name").Value;
                project.Path = projectNode.Attributes.GetNamedItem("Path").Value;

                XmlDocument projectReader = new XmlDocument();
                projectReader.Load(Path.GetDirectoryName(workspacePath) + Path.DirectorySeparatorChar + project.Path);

                // Files
                project.CodeFiles = new List<string>();

                foreach (XmlNode directoryNode in projectReader.SelectNodes("CodeLite_Project/VirtualDirectory"))
                {
                    ParseVirtualDirectory(directoryNode, project);
                }

                // Dependencies
                project.Dependencies = new List<Dependencies>();

                foreach (XmlNode dependencyNode in projectReader.SelectNodes("CodeLite_Project/Dependencies"))
                {
                    if (dependencyNode.Attributes.GetNamedItem("Name") != null)
                    {
                        Dependencies dependencies = new Dependencies();
                        project.Dependencies.Add(dependencies);
                        dependencies.Name = dependencyNode.Attributes.GetNamedItem("Name").Value;

                        XmlNodeList dependencyProjects = dependencyNode.SelectNodes("Project");

                        dependencies.ProjectNames = new List<string>();

                        foreach (XmlNode dependencyProjectNode in dependencyProjects)
                        {
                            dependencies.ProjectNames.Add(dependencyProjectNode.Attributes.GetNamedItem("Name").Value);
                        }
                    }
                }

                // Configurations
                project.Configurations = new List<CodeLiteProjectConfiguration>();

                foreach (XmlNode configNode in projectReader.SelectSingleNode("CodeLite_Project/Settings").SelectNodes("Configuration"))
                {
                    project.Configurations.Add(ParseProjectConfiguration(configNode));
                }

                // Global settings
                project.GlobalConfiguration = ParseProjectConfiguration(projectReader.SelectSingleNode("CodeLite_Project/Settings").SelectSingleNode("GlobalSettings"));
            }

            return workspace;
        }