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
Add(string, string)
Adds items to the list the user set for a setting whose value is a list (TextList, DiagnosticCodeList): each that the list does not hold already, without regard to case, after the items it holds.
public UserSettingChange Add(string key, string value)
Parameters
keystringThe key of the setting, without regard to case:
analysis.disabledDiagnostics.valuestringThe item, or items, as they are written (TryParse(SettingDescriptor, string, out object?)):
RDC01001.
Returns
- UserSettingChange
What became of the value: it is set when the list holds the items, and the file is written only when it did not already.
Remarks
The list is the one the user set: a list the user did not set is an empty one, and what the deployed configuration says of the setting is not part of it.
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
Remove(string, string)
Removes items from the list the user set for a setting whose value is a list (TextList, DiagnosticCodeList), without regard to case. The last item removed leaves an empty list, which the user set.
public UserSettingChange Remove(string key, string value)
Parameters
keystringThe key of the setting, without regard to case:
analysis.disabledDiagnostics.valuestringThe item, or items, as they are written (TryParse(SettingDescriptor, string, out object?)):
RDC01001.
Returns
- UserSettingChange
What became of the value: it is set when the list does not hold the items, and the file is written only when it did.
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.