namespace PixiEditor.Extensions.CommonApi.UserPreferences;
public interface IPreferences
{
public static IPreferences Current { get; private set; }
///
/// Saves the preferences to be stored permanently.
///
public void Save();
///
/// Adds a callback that will be executed when the setting called changes.
///
/// The name of the setting
/// The action that will be executed when the setting changes
public void AddCallback(string name, Action action);
///
/// Adds a callback that will be executed when the setting called changes.
///
/// The of the setting
/// The name of the setting
/// The action that will be executed when the setting changes
public void AddCallback(string name, Action action);
public void RemoveCallback(string name, Action action);
public void RemoveCallback(string name, Action action);
///
/// Initializes the preferences.
///
public void Init();
///
/// Initializes the preferences using the and
///
public void Init(string path, string localPath);
///
/// Updates a user preference and calls all added callbacks.
///
/// The of the setting
/// The name of the setting.
/// The new value.
public void UpdatePreference(string name, T value);
///
/// Updates a editor setting and calls all added callbacks.
///
/// The of the setting
/// The name of the setting
/// The new value
public void UpdateLocalPreference(string name, T value);
#nullable enable
///
/// Reads the user preference that is called , if the setting does not exist the default of will be used
///
/// The of the setting
/// The name of the setting
/// The setting or the default of if it has not been set yet
public T? GetPreference(string name);
///
/// Reads the user preference that is called , if the setting does not exist the default of will be used
///
/// The of the setting
/// The name of the setting
/// The setting or the if it has not been set yet
public T? GetPreference(string name, T? fallbackValue);
///
/// Reads the editor setting that is called , if the setting does not exist the deafult of will be used
///
/// The of the setting
/// The name of the setting
/// The editor setting or the default of if it has not been set yet
public T? GetLocalPreference(string name);
///
/// Reads the editor setting that is called , if the setting does not exist the will be used
///
/// The of the setting
/// The name of the setting
/// The editor setting or the if it has not been set yet
public T? GetLocalPreference(string name, T? fallbackValue);
protected static void SetAsCurrent(IPreferences provider)
{
Current = provider;
}
}