A very simple low-friction approach to persisting settings.
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";
});