Пример #1
0
        public void InitializeSolution(Solution solution)
        {
            ReadNextLine();
            solution.Version = GetSolutionVersion(_currentLine);

            Match match;
            SolutionRootNodeType nodeType = SolutionRootNodeType.Unknown;

            ReadNextLine();

            while ((nodeType = GetCurrentRootNodeType(out match)) != SolutionRootNodeType.Unknown)
            {
                switch (nodeType)
                {
                    case SolutionRootNodeType.Project:
                        solution.Nodes.Add(ReadProjectEntry(solution, match));
                        break;
                    case SolutionRootNodeType.Property:
                        break;
                    case SolutionRootNodeType.Global:
                        ReadGlobalSection(solution);
                        break;
                }
                ReadNextLine();
            }

            FixNestedProjects(solution);
        }
Пример #2
0
        public void WriteSolution(Solution solution)
        {
            WriteSolutionHeader(solution.Version);

            foreach (var node in solution.Nodes)
            {
                WriteNode(node);
            }

            _writer.WriteLine("Global");

            foreach (var section in solution.GlobalSections)
            {
                WriteSection(section);
            }

            _writer.WriteLine("EndGlobal");
        }
Пример #3
0
        private void FixNestedProjects(Solution solution)
        {
            var nestedProjectsSection = solution.GlobalSections.FirstOrDefault(x => x.Name == "NestedProjects");
            if (nestedProjectsSection != null)
            {
                foreach (var item in nestedProjectsSection)
                {
                    Guid projectGuid;
                    Guid folderGuid;

                    if (Guid.TryParse(item.Key, out projectGuid) && Guid.TryParse(item.Value, out folderGuid))
                    {
                        var project = solution.GetSolutionNode(x => x.ObjectGuid == projectGuid);
                        var folder = (SolutionFolder)solution.GetSolutionNode(x => x.ObjectGuid == folderGuid);
                        if (project != null && folder != null)
                        {
                            project.Parent.Nodes.Remove(project);
                            folder.Nodes.Add(project);
                        }
                    }
                }
            }
        }
Пример #4
0
        private SolutionFolder ReadProjectEntry(Solution parent, Match match)
        {
            string path = match.Groups["HintPath"].Value;
            SolutionFolder entry;

            Guid typeID = Guid.Parse(match.Groups["TypeGuid"].Value);

            if (typeID == SolutionFolder.SolutionFolderGuid)
            {
                entry = new SolutionFolder();
            }
            else
            {
                entry = new ProjectEntry();
            }

            entry.TypeGuid = typeID;
            entry.Name = match.Groups["Name"].Value;
            entry.FilePath = new FilePath(parent.FilePath.ParentDirectory.FullPath, match.Groups["HintPath"].Value);
            entry.ObjectGuid = Guid.Parse(match.Groups["ProjectGuid"].Value);

            ReadNextLine();

            Match sectionMatch;
            while (IsAtSection(out sectionMatch))
            {
                entry.Sections.Add(ReadSection(sectionMatch));
                ReadNextLine();
            }

            if (_currentLine != "EndProject")
                ThrowSyntaxError("Expected \"EndProject\" keyword.");

            return entry;
        }
Пример #5
0
        private void ReadGlobalSection(Solution parent)
        {
            Match match;

            ReadNextLine();

            while (IsAtSection(out match))
            {
                var section = ReadSection(match);
                if (section.SectionType != "Global")
                    ThrowSyntaxError("Expected \"GlobalSection\" keyword.");

                parent.GlobalSections.Add(section);

                ReadNextLine();
            }

            if (_currentLine != "EndGlobal")
                ThrowSyntaxError("Expected \"EndGlobal\" keyword.");
        }
Пример #6
0
 public SolutionEventArgs(Solution file)
 {
     TargetSolution = file;
 }
 private void _extensionHost_SolutionUnload(object sender, SolutionEventArgs e)
 {
     _solution = null;
     mainTreeView.Nodes.Clear();
 }
 private void _extensionHost_SolutionLoad(object sender, SolutionEventArgs e)
 {
     _solution = _extensionHost.CurrentSolution;
     _solution.Settings.StartupProjects.InsertedItem += StartupProjects_Changed;
     _solution.Settings.StartupProjects.RemovedItem += StartupProjects_Changed;
     contextMenuStrip1.Renderer = _extensionHost.ControlManager.MenuRenderer;
     mainTreeView.Nodes.Add(new SolutionNode(_solution, _iconProvider));
 }
Пример #9
0
        /// <summary>
        /// Opens an existing solution file and parses out the sub projects.
        /// </summary>
        /// <param name = "solutionFile">The file path to the solution file.</param>
        public static Solution OpenSolution(string solutionFile)
        {
            using (var reader = new StreamReader(solutionFile))
            {
                using (var solutionReader = new SolutionReader(reader))
                {
                    var solution = new Solution();
                    solution.FilePath = new FilePath(solutionFile);
                    solution.Name = solution.FilePath.FileName;
                    solutionReader.InitializeSolution(solution);
                    solution.InitializeEventHandlers();

                    var settingsPath = solution.FilePath.ChangeExtension(".litesettings").FullPath;
                    if (File.Exists(settingsPath))
                    {
                        try
                        {
                            var settings = SolutionSettings.ReadSettings(settingsPath);
                            solution.Settings = settings;
                        }
                        catch
                        {
                            // TODO: notify user
                        }
                    }

                    return solution;
                }
            }
        }
Пример #10
0
 public SolutionNode(Solution solution, IconProvider iconProvider)
     : base(solution, iconProvider)
 {
     Solution = solution;
 }