Skip to content

Latest commit

 

History

History
48 lines (42 loc) · 2.21 KB

File metadata and controls

48 lines (42 loc) · 2.21 KB

WritableJsonConfiguration

JSON

GitHub last commit GitHub code size in bytes

GitHub search hit counter Nuget

What is it?

If you want to add a settings to your app and you like json, then this is what you need. This uses the standard interface for working with settings, which is provided by Microsoft.Extensions.Configuration. To do this, we added methods for changing values in settings via the standard interface, which will edit the json file themselves.

How to use?

Add Nuget Package in your project:

Install-Package WritableJsonConfiguration

Create configuration:

IConfigurationRoot configuration = WritableJsonConfigurationFabric.Create("Settings.json");

Use this configuration in the app as you need, usually people register it with the IoC, example(Splat):

Locator.CurrentMutable.RegisterConstant(configuration, typeof(IConfiguration));

Get value:

Themes theme = configuration.GetSection("Appearance:Theme").Get<Themes>();

or

Themes theme = configuration.Get<Themes>("Appearance:Theme");

Set value:

configuration.GetSection("Appearance:Theme").Set(theme);

or

configuration.Set("Appearance:Theme", theme);

Communication

Any suggestions and comments are welcome. If you want to contact me, use Telegram