using Common.Logging;
namespace Common.AppSettings;
public interface IAppSettingsProvider
{
///
/// Any internal event inside of the App Settings Provider.
///
event EventHandler? LogWorthyEvent;
///
/// Retrieves the app settings from the persistant location and loads them into memory.
/// Loading settings will override the currently stored settings in the memory.
/// If loading happens and there were already settings in the memory, a is generated.
///
void Load();
///
/// Saves the app settings to the persistant location.
/// If the saving does not work, logs the exception as a but does not throw an exception.
/// Rationale: A User is happier if the app is useable and does not remember settings than if the app always throws an exception on startup.
///
void Save();
///
/// Creates a new setting or overwrites the value of an existing setting in the memory (not persistent location). Settings are identified by key.
/// Informs about issues using the .
///
/// key of the setting, must not be empty or null
/// value of the setting, must not be empty or null
/// true if the setting is successfully written or overwritten
bool WriteSetting(string key, string value);
///
/// Tries to read a setting from the memory (not persistent location). Settings are identified by key.
/// Informs about issues using the .
/// If no setting with the given is found, the is set to .
///
/// key of the setting, must not be empty or null
/// the found value or an empty string if no setting is found
/// true when the setting exists and could be read successfully
bool TryReadSetting(string key, out string value);
///
/// Tries to read a setting from the memory (not persistent location). Settings are identified by key.
/// Informs about issues using the .
/// If no setting with the given is found, the setting is created with the given . is also set to .
///
/// key of the setting, must not be empty or null
/// the found value or an empty string if no setting is found
/// the default value to initialize the setting with if it does not exist yet. must not be empty or null
/// true when the setting could be read or was created successfully
bool TryReadSettingOrAddDefault(string key, out string value, string defaultValue);
}