Skip to content

JsonFileApplicationSettingsService class

The default IApplicationSettingsService: keeps the values in a JSON file in the per-user application data folder, so they survive a restart of the application.

Namespace: Eremex.AvaloniaUI.Controls.ApplicationServices
Assembly: Eremex.Avalonia.Controls.ApplicationServices.dll
NuGet Package: Eremex.Avalonia.Controls.ApplicationServices

Declaration

public class JsonFileApplicationSettingsService : IApplicationSettingsService

Constructors

name description
JsonFileApplicationSettingsService() Initializes a new instance that stores the values in the default per-user location.
JsonFileApplicationSettingsService(…) Initializes a new instance that stores the values in the given file.

Properties

name description
FilePath { get; } The path of the file the values are stored in.

Methods

name description
Remove(…)
SetValue<T>(…)
TryGetValue<T>(…)

Remarks

The file is settings.json in a folder named after the entry assembly, inside %AppData% on Windows, ~/Library/Application Support on macOS and $XDG_CONFIG_HOME (~/.config by default) on Linux. The file is read on first use and rewritten after every change. A missing, unreadable or corrupt file is treated as empty, and a failure to write never throws: the values stay available in memory for the rest of the session.

See Also