示例#1
0
文件: SlnFile.cs 项目: shuruev/Atom
        public SlnFileBrowser(SlnFileData data)
        {
            Data = data;

            _projectInfos    = new Lazy <Dictionary <string, SlnFileProject> >(LoadProjectInfos);
            _solutionFolders = new Lazy <HashSet <string> >(LoadSolutionFolders);
            _nestedProjects  = new Lazy <Dictionary <string, string> >(LoadNestedProjects);
        }
示例#2
0
文件: SlnFile.cs 项目: shuruev/Atom
        public static List <string> RenderLines(SlnFileData data)
        {
            var list = new List <string>();

            list.AddRange(RenderHeader(data.Header));
            list.AddRange(data.Projects.SelectMany(RenderProject));
            list.Add("Global");
            list.AddRange(data.GlobalSections.SelectMany(RenderGlobalSection));
            list.Add("EndGlobal");
            return(list);
        }
示例#3
0
文件: SlnFile.cs 项目: shuruev/Atom
 public static SlnFileBrowser Browse(this SlnFileData data) => new(data);
示例#4
0
文件: SlnFile.cs 项目: shuruev/Atom
 public static void WriteToFile(SlnFileData data, string path) => File.WriteAllLines(path, RenderLines(data));
示例#5
0
文件: SlnFile.cs 项目: shuruev/Atom
        public static SlnFileData ParseLines(IEnumerable <string> lines)
        {
            var data = new SlnFileData();

            SlnFileProject?currentProject        = null;
            SlnFileSection?currentProjectSection = null;
            SlnFileSection?currentGlobalSection  = null;

            foreach (var line in lines)
            {
                if (String.IsNullOrEmpty(line))
                {
                    continue;
                }

                if (currentProject != null)
                {
                    if (currentProjectSection != null)
                    {
                        if (ParseProjectSectionEnd(line))
                        {
                            currentProject.ProjectSections.Add(currentProjectSection);
                            currentProjectSection = null;
                            continue;
                        }

                        var property = ParseSectionPropertyLine(line);
                        currentProjectSection.Properties.Add(property);
                        continue;
                    }

                    if (ParseProjectSectionBegin(line, out var projSec))
                    {
                        currentProjectSection = projSec;
                        continue;
                    }

                    if (ParseProjectEnd(line))
                    {
                        data.Projects.Add(currentProject);
                        currentProject = null;
                        continue;
                    }
                }

                if (currentGlobalSection != null)
                {
                    if (ParseGlobalSectionEnd(line))
                    {
                        data.GlobalSections.Add(currentGlobalSection);
                        currentGlobalSection = null;
                        continue;
                    }

                    var property = ParseSectionPropertyLine(line);
                    currentGlobalSection.Properties.Add(property);
                    continue;
                }

                if (ParseHeaderLine(data.Header, line))
                {
                    continue;
                }

                if (ParseProjectBegin(line, out var proj))
                {
                    currentProject = proj;
                    continue;
                }

                if (ParseGlobal(line))
                {
                    continue;
                }

                if (ParseGlobalSectionBegin(line, out var globSec))
                {
                    currentGlobalSection = globSec;
                    continue;
                }

                throw new InvalidOperationException($"Unexpected solution line: {line}");
            }

            return(data);
        }