Nucs / JsonSettings

This library simplifies creating configuration for your C# app/service by utilizing the serialization capabilities of Json.NET to serialize nested (custom) objects, dictionaries and lists as simply as by creating a POCO and inheriting JsonSettings class.
MIT License
76 stars 18 forks source link

difference between these #4

Closed ghost1372 closed 6 years ago

ghost1372 commented 6 years ago

hi whats difference between these two? SettingsBag Settings = JsonSettings.Load<SettingsBag>("config.json").EnableAutosave(); SettingsBag Settings { get; } = JsonSettings.Construct<SettingsBag>("config.json").EnableAutosave().LoadNow();

Nucs commented 6 years ago

EnableAutosave is a feature of SettingsBag and is NOT a module. so it doesn't matter when you enable/call it as long as it is before you try to access one of the settings.

Construct and LoadNow(); is used to load modules into the settings class (see modules in wiki).

For example: if your file is supposed to be encrypted using WithEncryption("pass") module, you need to first load the module and only then load the file (just like on the second example).

JsonSettings.Construct<SettingsBag>("config.json").EnableAutosave().WithEncryption("pass").LoadNow();
ghost1372 commented 6 years ago

tnx