Skip to content
ConsoleMonster

API Reference

Class

ChoiceStore

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 System.String requiredposition: 0
The app name (a folder name; unsafe characters are replaced).
root System.String? = null optionalposition: 1
The folder that holds every app's folder; null uses the per-user default.

Methods

public static String DefaultRoot() #
Returns: String

The per-user root: the roaming AppData folder on Windows, the XDG config folder elsewhere.

Returns

The folder.

public Boolean DeletePreset(String form, String name) #
Returns: Boolean

Deletes a preset.

Parameters

form System.String requiredposition: 0
The form key.
name System.String requiredposition: 1
The preset name.

Returns

Whether it existed.

public IDictionary<String, Object?>? LoadLast(String form) #
Returns: IDictionary<String, Object?>?

Loads the remembered choices of a form.

Parameters

form System.String requiredposition: 0
The form key.

Returns

The values, or null.

public IDictionary<String, Object?>? LoadPreset(String form, String name) #
Returns: IDictionary<String, Object?>?

Loads a preset.

Parameters

form System.String requiredposition: 0
The form key.
name System.String requiredposition: 1
The preset name.

Returns

The values, or null.

public IReadOnlyList<String> PresetNames(String form) #
Returns: IReadOnlyList<String>

The preset names saved for a form.

Parameters

form System.String requiredposition: 0
The form key (its title by default).

Returns

The names, sorted.

public Void SaveLast(String form, IDictionary<String, Object?> values) #
Returns: Void

Remembers the choices of a form.

Parameters

form System.String requiredposition: 0
The form key.
values System.Collections.Generic.IDictionary<System.String, System.Object?> requiredposition: 1
The values.
public Void SavePreset(String form, String name, IDictionary<String, Object?> values) #
Returns: Void

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

Parameters

form System.String requiredposition: 0
The form key.
name System.String requiredposition: 1
The preset name.
values System.Collections.Generic.IDictionary<System.String, System.Object?> requiredposition: 2
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.