Template10
Template10 copied to clipboard
Exception handling in SettingsService
Currently possible exceptions are not directly handled and caught in the SettingsService. Would it be better to handle them here?
example Settings/Adapters/LocalFileSettingsAdapter.cs new
public (bool successful, string result) ReadString(string key)
{
if (_container.Values.ContainsKey(key))
{
return (true, _container.Values[key].ToString());
}
else
{
return (false, string.Empty);
}
}
old
public string ReadString(string key)
=> _container.Values[key].ToString();
I have already implemented many things in my fork: https://github.com/jp-weber/Template10/tree/master/Source/Template10.Extras/Services/Settings
@jp-weber how about creating a repo dedicated to Settings? Windows-XAML/Template10.SettingsService
. Interested? THe many things you have already done are pretty handy for developers and we could brand it Template 10 and pub to Nuget.
@JerryNixon Yes I would like to do that 😀
I wonder if bool TryRead<T>(string key, out T value)
would be a better signature.