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
fileSystemIFileSystemThe file system the file is in.
pathstringThe path of the file.
schemaSettingsSchemaThe 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
Properties
FilePath
The path of the file.
public string FilePath { get; }
Property Value
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
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
environmentIPlatformEnvironmentThe platform's environment.
Returns
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
Reset(string?)
Removes what the user set, so that the deployed configuration says it again.
public int Reset(string? key = null)
Parameters
keystringThe 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
keystringThe key of the setting, without regard to case:
server.verbose.valuestringThe 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.