Table of Contents

Class UserSettingsStore

Namespace
RDCore.SDK.Server.Configuration
Assembly
RDCore.SDK.dll

The settings a user set for themselves, which take the place of what the deployed configuration says: the file user.settings.json, in the folder of the platform's user (UserDataDirectory).

public sealed class UserSettingsStore
Inheritance
UserSettingsStore
Inherited Members

Remarks

The file has the shape of an appsettings.json ({ "Configuration": { "Server": { "Verbose": false } } }), and holds only what the user set: a deployed appsettings.json is never written to, so that what it says is always there to go back to, and what the user set outlives a platform that is deployed again. Going back to the deployed configuration is removing what the user set (Reset(string?)).

A value is set only for a setting of the schema that a user can set, and only when it is one the setting can be: a file this writes never keeps the platform from starting. What is read from the file is checked again when the platform starts (AddUserSettings(IConfigurationBuilder, string, SettingsSchema, bool)), for a file that was written by hand.

Constructors

UserSettingsStore(IFileSystem, string, SettingsSchema)

The settings a user set for themselves, which take the place of what the deployed configuration says: the file user.settings.json, in the folder of the platform's user (UserDataDirectory).

public UserSettingsStore(IFileSystem fileSystem, string path, SettingsSchema schema)

Parameters

fileSystem IFileSystem

The file system the file is in.

path string

The path of the file.

schema SettingsSchema

The settings that can be set.

Remarks

The file has the shape of an appsettings.json ({ "Configuration": { "Server": { "Verbose": false } } }), and holds only what the user set: a deployed appsettings.json is never written to, so that what it says is always there to go back to, and what the user set outlives a platform that is deployed again. Going back to the deployed configuration is removing what the user set (Reset(string?)).

A value is set only for a setting of the schema that a user can set, and only when it is one the setting can be: a file this writes never keeps the platform from starting. What is read from the file is checked again when the platform starts (AddUserSettings(IConfigurationBuilder, string, SettingsSchema, bool)), for a file that was written by hand.

Fields

FileName

The name of the file.

public const string FileName = "user.settings.json"

Field Value

string

Properties

FilePath

The path of the file.

public string FilePath { get; }

Property Value

string

IsReadable

Whether the file can be read: it is not there, or it is a JSON object. A file that cannot be read is not written over, and the platform starts as if it were not there; resetting every setting (Reset(string?)) deletes it.

public bool IsReadable { get; }

Property Value

bool

Methods

PathIn(IPlatformEnvironment)

The path of the file of the user's settings, in the folder of the platform's user.

public static string PathIn(IPlatformEnvironment environment)

Parameters

environment IPlatformEnvironment

The platform's environment.

Returns

string

Read()

The values the user set, of the settings of the schema that a user can set, in the order of the schema.

public IReadOnlyList<UserSettingValue> Read()

Returns

IReadOnlyList<UserSettingValue>

Reset(string?)

Removes what the user set, so that the deployed configuration says it again.

public int Reset(string? key = null)

Parameters

key string

The key of a setting, or of a section - every setting in it: Server.Verbose, Server; without regard to case. null for every setting, which deletes the file whether or not it can be read.

Returns

int

How many values the user had set that are removed.

Set(string, string)

Sets the value of a setting for the user.

public UserSettingChange Set(string key, string value)

Parameters

key string

The key of the setting, without regard to case: server.verbose.

value string

The value, as it is written (TryParse(SettingDescriptor, string, out object?)).

Returns

UserSettingChange

What became of the value: the file is written only when it is set.