/// <summary> /// Unloads solution-specific settings from the specified settings object. /// </summary> /// <param name="settings">The settings to update.</param> /// <returns>True if solution-specific settings were unloaded, otherwise false.</returns> internal bool UnloadSolutionSpecificSettings(Settings settings) { // Determine if there is a solution-specific settings file. if (settings.Context.ContainsKey("SolutionPath")) { // Unload the solution settings from the given settings (restore to user settings only). settings.Context.Remove("SolutionPath"); settings.Reload(); return true; } return false; }
/// <summary> /// Loads the specified settings object with solution-specific settings if they exist or can /// be created. /// </summary> /// <param name="settings">The settings to update.</param> /// <param name="canCreate">A flag indicating if solution-specific settings can be created.</param> /// <returns>True if solution-specific settings were loaded, otherwise false.</returns> internal bool LoadSolutionSpecificSettings(Settings settings, bool canCreate = false) { if (_package.IDE.Solution.IsOpen) { var solutionPath = Path.GetDirectoryName(_package.IDE.Solution.FullName); if (!string.IsNullOrWhiteSpace(solutionPath)) { var solutionConfig = Path.Combine(solutionPath, SettingsFilename); // Determine if there is a solution-specific settings file or one can be created. if (File.Exists(solutionConfig) || canCreate) { // Reload the solution settings into the given settings (merge on top of user settings). settings.Context["SolutionPath"] = solutionPath; settings.Reload(); return true; } } } return false; }