コード例 #1
0
ファイル: SolutionWriter.cs プロジェクト: mstanford/water
        /// <summary>
        /// Writes a solution to a file.
        /// </summary>
        /// <param name="solution"></param>
        /// <param name="filename"></param>
        public static void Write(Models.Solution solution, System.IO.TextWriter writer)
        {
            writer.WriteLine("Microsoft Visual Studio Solution File, Format Version 8.00");
            foreach (Models.Project project in solution.Projects)
            {
                writer.WriteLine("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"" + project.Name + "\", \"" + project.Path + "\", \"{" + project.Guid.ToString().ToUpper() + "}\"");
                writer.WriteLine("	ProjectSection(ProjectDependencies) = postProject");
                writer.WriteLine("	EndProjectSection");
                writer.WriteLine("EndProject");
            }
            writer.WriteLine("Global");
            writer.WriteLine("	GlobalSection(SolutionConfiguration) = preSolution");
            writer.WriteLine("		Debug = Debug");
            writer.WriteLine("		Release = Release");
            writer.WriteLine("	EndGlobalSection");
            writer.WriteLine("	GlobalSection(ProjectConfiguration) = postSolution");
            foreach (Models.Project project in solution.Projects)
            {
                writer.WriteLine("		{"+ project.Guid.ToString().ToUpper() + "}.Debug.ActiveCfg = Debug|.NET");
                writer.WriteLine("		{"+ project.Guid.ToString().ToUpper() + "}.Debug.Build.0 = Debug|.NET");
                writer.WriteLine("		{"+ project.Guid.ToString().ToUpper() + "}.Release.ActiveCfg = Release|.NET");
                writer.WriteLine("		{"+ project.Guid.ToString().ToUpper() + "}.Release.Build.0 = Release|.NET");
            }
            writer.WriteLine("	EndGlobalSection");
            writer.WriteLine("	GlobalSection(ExtensibilityGlobals) = postSolution");
            writer.WriteLine("	EndGlobalSection");
            writer.WriteLine("	GlobalSection(ExtensibilityAddIns) = postSolution");
            writer.WriteLine("	EndGlobalSection");
            writer.WriteLine("EndGlobal");

            writer.Flush();
        }
コード例 #2
0
        /// <summary>
        /// Reads a solution from a file, and returns the solution.
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static Models.Solution Read(string name, System.IO.TextReader reader)
        {
            Models.Solution solution = new Models.Solution();

            solution.Name = name;

            LoadSolution(reader, solution);

            return(solution);
        }
コード例 #3
0
        public static Models.Solution Read(string filename)
        {
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(filename);
            string             name     = fileInfo.Name.Substring(0, fileInfo.Name.Length - fileInfo.Extension.Length);

            System.IO.TextReader reader   = System.IO.File.OpenText(filename);
            Models.Solution      solution = Read(name, reader);
            reader.Close();
            return(solution);
        }
コード例 #4
0
ファイル: SolutionBuilder.cs プロジェクト: mstanford/water
        public void Build(string filename, string configuration)
        {
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(filename);
            string             name     = fileInfo.Name.Substring(0, fileInfo.Name.ToLower().LastIndexOf(".sln"));

            System.IO.TextReader reader   = fileInfo.OpenText();
            Models.Solution      solution = SolutionReader.Read(filename, reader);
            reader.Close();

            string projectFolder = LastLeft(filename, System.IO.Path.DirectorySeparatorChar.ToString());

            this.Build(solution, configuration, projectFolder, String.Empty);
        }
コード例 #5
0
        private static void LoadProject(string line, Models.Solution solution)
        {
            string[] sublines = line.Substring(line.IndexOf("=") + 1).Split(",".ToCharArray());
            string   name     = sublines[0].Trim().Substring(1, sublines[0].Trim().Length - 2);
            string   path     = sublines[1].Trim().Substring(1, sublines[1].Trim().Length - 2);

            System.Guid guid = new System.Guid(sublines[2].Trim().Substring(1, sublines[2].Trim().Length - 2));

            Models.Project project = new Models.Project();
            project.Name = name;
            project.Path = path;
            project.Guid = guid;
            solution.Projects.Add(project);
        }
コード例 #6
0
        private static void LoadConfigurations(System.IO.TextReader reader, Models.Solution solution)
        {
            while (reader.Peek() != -1)
            {
                string line = reader.ReadLine();

                if (line.StartsWith("	EndGlobalSection"))
                {
                    return;
                }

                Models.Config config = new Models.Config();
                config.Name = line.Split("=".ToCharArray())[0].Trim();
                solution.Configs.Add(config);
            }
        }
コード例 #7
0
        private static void LoadSolution(System.IO.TextReader reader, Models.Solution solution)
        {
            if (reader.Peek() == -1)
            {
                reader.Read();
            }
            while (reader.Peek() != -1)
            {
                string line = reader.ReadLine();

                if (line.StartsWith("Project"))
                {
                    LoadProject(line, solution);
                }
                else if (line.StartsWith("	GlobalSection(SolutionConfiguration)"))
                {
                    LoadConfigurations(reader, solution);
                }
            }
        }