/// <summary> /// Sets the values of the specified group of property settings. /// </summary> /// <param name="context"> /// A <see cref="T:System.Configuration.SettingsContext"/> describing the current /// application usage. /// </param> /// <param name="values"> /// A <see cref="T:System.Configuration.SettingsPropertyValueCollection"/> representing the /// group of property settings to set. /// </param> public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection values) { try { var settingsPath = SettingsContextHelper.GetSolutionSettingsPath(context) ?? SettingsContextHelper.GetUserSettingsPath(); var sectionName = GetSectionName(context); WriteSettingsToFile(settingsPath, sectionName, values); } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine("Unable to SetPropertyValues.", ex); throw; } }
/// <summary> /// Returns the collection of setting property values for the specified application instance /// and settings property group. /// </summary> /// <param name="context"> /// A <see cref="T:System.Configuration.SettingsContext"/> describing the current /// application usage. /// </param> /// <param name="properties"> /// A <see cref="T:System.Configuration.SettingsPropertyCollection"/> containing the /// settings property group whose values are to be retrieved. /// </param> /// <returns> /// A <see cref="T:System.Configuration.SettingsPropertyValueCollection"/> containing the /// values for the specified settings property group. /// </returns> public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection properties) { try { var solutionSettingsPath = SettingsContextHelper.GetSolutionSettingsPath(context); var userSettingsPath = SettingsContextHelper.GetUserSettingsPath(); var sectionName = GetSectionName(context); var userSettings = ReadSettingsFromFile(userSettingsPath, sectionName); var solutionSettings = ReadSettingsFromFile(solutionSettingsPath, sectionName); var propertyValues = MergeSettingsIntoPropertyValues(userSettings, solutionSettings, properties); return(propertyValues); } catch (Exception ex) { OutputWindowHelper.ExceptionWriteLine("Unable to GetPropertyValues.", ex); throw; } }
/// <summary> /// Gets an instance of the <see cref="SettingsContextHelper" /> class. /// </summary> /// <param name="package">The hosting package.</param> /// <returns>An instance of the <see cref="SettingsContextHelper" /> class.</returns> internal static SettingsContextHelper GetInstance(CodeMaidPackage package) { return(_instance ?? (_instance = new SettingsContextHelper(package))); }