{"id":19626613,"url":"https://github.com/softcircuits/winsettings","last_synced_at":"2026-03-12T08:20:26.214Z","repository":{"id":35010788,"uuid":"196277398","full_name":"SoftCircuits/WinSettings","owner":"SoftCircuits","description":".NET class library that makes it easy to save and retrieve application settings in INI files, XML files or the Windows registry.","archived":false,"fork":false,"pushed_at":"2022-10-27T20:48:02.000Z","size":73,"stargazers_count":7,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-03T09:20:07.917Z","etag":null,"topics":["application-settings","ini-parser","ini-settings","registry","registry-settings","xml-parser","xml-settings"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SoftCircuits.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-10T21:30:03.000Z","updated_at":"2023-03-07T12:44:16.000Z","dependencies_parsed_at":"2023-01-15T11:57:15.189Z","dependency_job_id":null,"html_url":"https://github.com/SoftCircuits/WinSettings","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftCircuits%2FWinSettings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftCircuits%2FWinSettings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftCircuits%2FWinSettings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftCircuits%2FWinSettings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SoftCircuits","download_url":"https://codeload.github.com/SoftCircuits/WinSettings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224098974,"owners_count":17255545,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["application-settings","ini-parser","ini-settings","registry","registry-settings","xml-parser","xml-settings"],"created_at":"2024-11-11T11:47:09.723Z","updated_at":"2026-03-12T08:20:26.168Z","avatar_url":"https://github.com/SoftCircuits.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WinSettings\n\n[![NuGet version (SoftCircuits.WinSettings)](https://img.shields.io/nuget/v/SoftCircuits.WinSettings.svg?style=flat-square)](https://www.nuget.org/packages/SoftCircuits.WinSettings/)\n\n```\nInstall-Package SoftCircuits.WinSettings\n```\n\n## Overview\n\nWinSettings is a .NET class library that makes it easy to save and retrieve application settings on Windows. It includes three settings classes: `IniSettings`, which stores the settings to an INI file; `XmlSettings`, which stores the settings to an XML file, and `RegistrySettings`, which stores the settings to the Windows registry. In addition, it makes it easy to define your own settings type.\n\nSettings can be encrypted just by adding a property attribute. There is also an attribute to exclude a particular property when the property is used internally and does not represent an application setting.\n\nTo use a settings class, simply derive your own settings class from one of the ones described above and add public properties that you want to be saved. Your class' constructor should set any default values. Then call the `Save()` and `Load()` methods to save the settings in your class.\n\n## IniSettings Class\n\nThe \u003csee cref=\"IniSettings\"/\u003e class makes it very easy to save your application settings to an INI file.\n\nTo use the class, simply derive your own settings class from `IniSettings` and add the public properties that you want to be saved as settings. You can then call the `Load()` and `Save()` methods to read or write those settings to an INI file.\n\nYour derived class' constructor should initialize your settings properties to their default values.\n\nTwo attributes are available for public properties in your derived class. The first is `EncryptedSettingAttribute`. Use this attribute if you want the setting to be encrypted when saved to file. When using this attribute on any property, you must provide a valid encryption password to the `IniSettings` constructor.\n\nThe second is the `ExcludedSettingAttribute`. Use this attribute on any properties that are used internally by your code and should not saved to file.\n\nAll public properties without the `ExcludedSettingAttribute` attribute must be of one of the supported data types. This includes all the basic data types as well as `string[]` and `byte[]`. All other types will raise an exception. In addition, INI files do not support strings that contain newlines unless those strings are encrypted.\n\n#### Example\n\nThe following example creates a settings class called `MySettings` with several properties, two of which are encrypted when saved to file.\n\n```cs\npublic class MySettings : IniSettings\n{\n    // Define properties to be saved to file\n    public string EmailHost { get; set; }\n    public int EmailPort { get; set; }\n\n    // The following properties will be encrypted\n    [EncryptedSetting]\n    public string UserName { get; set; }\n    [EncryptedSetting]\n    public string Password { get; set; }\n\n    // The following property will not be saved to file\n    // Non-public properties are also not saved to file\n    [ExcludedSetting]\n    public DateTime Created { get; set; }\n\n    public MySettings(string filename)\n        : base(filename, \"Password123\")\n    {\n        // Set initial, default property values\n        EmailHost = string.Empty;\n        EmailPort = 0;\n        UserName = string.Empty;\n        Password = string.Empty;\n\n        Created = DateTime.Now;\n    }\n}\n```\n\n## XmlSettings Class\n\nThe \u003csee `XmlSettings` class makes it very easy to save your application settings to an XML file.\n\nTo use the class, simply derive your own settings class from `XmlSettings` and add the public properties that you want to be saved as settings. You can then call the `Load()` and `Save()` methods to read or write those settings to an XML file.\n\nYour derived class' constructor should initialize your settings properties to their default values.\n\nTwo attributes are available for public properties in your derived class. The first is `EncryptedSettingAttribute`. Use this attribute if you want the setting to be encrypted when saved to file. When using this attribute on any property, you must provide a valid encryption password to the `XmlSettings` constructor.\n\nThe second is the `ExcludedSettingAttribute` Use this attribute on any properties that are used internally by your code and should not saved to file.\n\nAll public properties without the `ExcludedSettingAttribute` attribute must be of one of the supported data types. This includes all the basic data types `string[]` and `byte[]`. All other types will raise an exception.\n\n#### Example\n\nThe following example creates a settings class called `MySettings` with several properties, two of which are encrypted when saved to file.\n\n```cs\npublic class MySettings : XmlSettings\n{\n    // Define properties to be saved to file\n    public string EmailHost { get; set; }\n    public int EmailPort { get; set; }\n\n    // The following properties will be encrypted\n    [EncryptedSetting]\n    public string UserName { get; set; }\n    [EncryptedSetting]\n    public string Password { get; set; }\n\n    // The following property will not be saved to file\n    // Non-public properties are also not saved to file\n    [ExcludedSetting]\n    public DateTime Created { get; set; }\n\n    public MySettings(string filename)\n        : base(filename, \"Password123\")\n    {\n        // Set initial, default property values\n        EmailHost = string.Empty;\n        EmailPort = 0;\n        UserName = string.Empty;\n        Password = string.Empty;\n\n        Created = DateTime.Now;\n    }\n}\n```\n\n## RegistrySettings Class\n\nThe `RegistrySettings` class makes it very easy to save your application settings to the system registry.\n\nTo use the class, simply derive your own settings class from `RegistrySettings` and add the public properties that you want to be\nsaved as settings. You can then call the `Load()` and `Save()` methods to read or write those settings to the system registry.\n\nYour derived class' constructor should initialize your settings properties to their default values.\n\nTwo attributes are available for public properties in your derived class. The first is `EncryptedSettingAttribute`. Use this attribute if you want the setting to be encrypted when saved to file. When using this attribute on any property, you must provide a valid encryption password to the `RegistrySettings` constructor.\n\nThe second is the `ExcludedSettingAttribute`. Use this attribute on any properties that are used internally by your code and should not saved to the registry.\n\nAll public properties without the `ExcludedSettingAttribute` attribute must be of one of the supported data types. This includes all the basic data types as well as `string[]` and `byte[]`. All other types will raise an exception.\n\n#### Example\n\nThe following example creates a settings class called `MySettings` with several properties, two of which are encrypted when saved to file.\n\n```cs\npublic class MySettings : RegistrySettings\n{\n    // Define properties to be saved to file\n    public string EmailHost { get; set; }\n    public int EmailPort { get; set; }\n\n    // The following properties will be encrypted\n    [EncryptedSetting]\n    public string UserName { get; set; }\n    [EncryptedSetting]\n    public string Password { get; set; }\n\n    // The following property will not be saved to file\n    // Non-public properties are also not saved to file\n    [ExcludedSetting]\n    public DateTime Created { get; set; }\n\n    public MySettings(string companyName, string applicationName, RegistrySettingsType settingsType)\n        : base(companyName, applicationName, settingsType, \"Password123\")\n    {\n        // Set initial, default property values\n        EmailHost = string.Empty;\n        EmailPort = 0;\n        UserName = string.Empty;\n        Password = string.Empty;\n\n        Created = DateTime.Now;\n    }\n}\n```\n\n## Settings Class\n\nThe `Settings` class is the base class for the `IniSettings`, `XmlSettings` and `RegistrySettings` classes. You don't need this class but you could use it to create your own type of custom settings class.\n\nTo do this, create your own `static`, `abstract` class that derives from `Settings` and override the virtual `OnSaveSettings()` and `OnLoadSettings()` methods.\n\nAs the name suggests, `OnSaveSettings()` is called when the settings are being saved. This method is passed a collection of `Setting` objects. Your handler needs to write these settings to your custom data store. The `Setting.Name` property contains the setting name. Use the `Setting.GetValue()` method to get the value. Or use the `Setting.GetValueAsString()` instead if your data store only supports string values.\n\nThe steps to override `OnLoadSettings()` is similar. This method is also passed a collection of `Setting` objects. Your handler needs to read each named setting from your custom data store. You can then set that value using the `Setting.SetValue()` or `Setting.SetValueFromString()` methods.\n\n## Dependencies\n\nThis project requires the NuGet packages [SoftCircuits.EasyEncryption](https://www.nuget.org/packages/SoftCircuits.EasyEncryption/) and Microsoft.Win32.Registry.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftcircuits%2Fwinsettings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftcircuits%2Fwinsettings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftcircuits%2Fwinsettings/lists"}