Skip to content
ConsoleMonster
Class

ChoiceStore

ConsoleMonster.Interactive

Namespace
ConsoleMonster.Interactive
Assembly
ConsoleMonster
Modifiers
sealed

Per-app storage of named presets and (opt-in) remembered choices, in %APPDATA%\ConsoleMonster\<app>\ on Windows and $XDG_CONFIG_HOME/ConsoleMonster/<app>/ (or ~/.config) elsewhere. Values are plain JSON (strings, booleans and lists); secrets are never stored.

Inheritance

  • object
  • ChoiceStore

Constructors

public ChoiceStore(string appName, string? root = null) #

Creates a store for an app.

Parameters

appName string required
The app name (a folder name; unsafe characters are replaced).
root string? = null optional
The folder that holds every app's folder; null uses the per-user default.

Methods

public static string DefaultRoot() #

The configured CONSOLEMONSTER_STORAGE_ROOT, or the per-user root: the roaming AppData folder on Windows, the XDG config folder elsewhere. A capture host can isolate presets without changing the program it runs.

Returns

string The folder.
public bool DeletePreset(string form, string name) #

Deletes a preset.

Parameters

form string required
The form key.
name string required
The preset name.

Returns

bool Whether it existed.
public IDictionary<string, object?>? LoadLast(string form) #

Loads the remembered choices of a form.

Parameters

form string required
The form key.

Returns

IDictionary<string, object?>? The values, or null.
public IDictionary<string, object?>? LoadPreset(string form, string name) #

Loads a preset.

Parameters

form string required
The form key.
name string required
The preset name.

Returns

IDictionary<string, object?>? The values, or null.
public IReadOnlyList<string> PresetNames(string form) #

The preset names saved for a form.

Parameters

form string required
The form key (its title by default).

Returns

IReadOnlyList<string> The names, sorted.
public void SaveLast(string form, IDictionary<string, object?> values) #

Remembers the choices of a form.

Parameters

form string required
The form key.
values System.Collections.Generic.IDictionary<string, object?> required
The values.
public void SavePreset(string form, string name, IDictionary<string, object?> values) #

Saves a preset (replacing one with the same name).

Parameters

form string required
The form key.
name string required
The preset name.
values System.Collections.Generic.IDictionary<string, object?> required
The values (strings, booleans, lists of strings).

Properties

public string AppName { get; } #

The app name.

public string Folder { get; } #

The folder the files live in.