예제 #1
0
 internal Solution()
 {
     GlobalSections = new EventBasedCollection<SolutionSection>();
     Settings = new SolutionSettings();
     _invoker = new MSBuildInvoker(this);
     _invoker.CompletedOperation += new BuildResultEventHandler(invoker_CompletedOperation);
 }
예제 #2
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);

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

                    solution.InitializeEventHandlers();
                    solution.Settings.HasChanged = false;

                    return solution;
                }
            }
        }