I wrote a code that read all the items from a json that contains all the configuration of my application. In this code I've a property called obj
:
public static SuperModel obj
{
get
{
string json = File.ReadAllText(SettingsConfig.ConfigFilePath);
var jsonObj = JsonConvert.DeserializeObject<SuperModel>(json);
return jsonObj;
}
}
SuperModel
is the class model that contains instance of other classes.
What I'm trying to achieve is update the json value and then call another method that should overwrite the file with the new json, like this:
Settings.obj.GeneralSettings.Language = "english";
Settings.Save();
But I've a problem, how can I monitor the change on obj
, for example in this case I've updated the Language
property of GeneralSettings
-> SuperModel
class, is possible store the updated object with Save()
method that overwrite the file?
I never encountered a similar situation.
How can I solve this?