Skip to content

Latest commit

 

History

History
44 lines (33 loc) · 886 Bytes

README.md

File metadata and controls

44 lines (33 loc) · 886 Bytes

SharpSettingsStore

A very simple low-friction approach to persisting settings.

SharpSettingsStore

Example

Settings definition:

[SettingName("my-settings")]
public class MySettings
{
    public MySettings()
    {
        MyString = "default";
        MyInt = 30;
    }
    
    public string MyString { get; set; }
    
    public int MyInt { get; set; }
}

Usage:

ISettingsService settingsService = /**/;

// Method 1
var settings = await settingsService.GetSetting<MySettings>();
settings.MyInt = 45;
settings.MyString = "updated";
await settingsService.SaveSetting(settings);

// Method 2
await settingsService.SaveSetting<MySettings>(x =>
{
    x.MyInt = 45;
    x.MyString = "updated";
});