UserSettings
Overview
Represents a configuration file.
UserSettings is a singleton class, use Default
method to get access to an instance of the class.
Use case
You can use UserSettings class when you need to store preferences, for example:
method SaveSettings;
begin
Sugar.UserSettings.Default.Write("StoreLoginName", true);
Sugar.UserSettings.Default.Write("LastLoginName", "User");
Sugar.UserSettings.Default.Save;
end;
method LoadSettings;
begin
writeLn(Sugar.UserSettings.Default.Read("StoreLoginName", false));
writeLn(Sugar.UserSettings.Default.Read("LastLoginName", ""));
end;
Output:
True
User
Location
- Reference: Sugar
- Namespace: Sugar
Clear mapped
Removes all settings.
method Clear
void Clear()
func Clear()
void Clear()
Sub Clear()
Default
Returns default instance of the class.
class method Default: UserSettings
static UserSettings Default()
static func Default() -> UserSettings
static UserSettings Default()
Shared Function Default() As UserSettings
Keys
Gets a list of all keys stored in settings.
property Keys: array of String read;
String[] Keys { get; }
var Keys: String... { get{} }
String[] Keys { __get; }
ReadOnly Property Keys() As String()
Reads a setting with specified key. If setting with that key can not be found then specified default value is returned.
Parameters:
- Key: The key for a setting.
- DefaultValue: The default value for a setting.
Reads a setting with specified key. If setting with that key can not be found then specified default value is returned.
Parameters:
- Key: The key for a setting.
- DefaultValue: The default value for a setting.
Reads a setting with specified key. If setting with that key can not be found then specified default value is returned.
Parameters:
- Key: The key for a setting.
- DefaultValue: The default value for a setting.
Reads a setting with specified key. If setting with that key can not be found then specified default value is returned.
Parameters:
- Key: The key for a setting.
- DefaultValue: The default value for a setting.
Remove mapped
Removes a setting with a specified key.
method Remove(Key: String)
void Remove(String Key)
func Remove(_ Key: String)
void Remove(String Key)
Sub Remove(Key As String)
Parameters:
- Key: The key for a setting.
Save mapped
Causes any buffered data to be written to a settings storage.
method Save
void Save()
func Save()
void Save()
Sub Save()
Writes a setting with specified key and value. If setting with that key already exists then its value is overriden.
Parameters:
- Key: The key for a setting.
- Value: The value for a setting.
Writes a setting with specified key and value. If setting with that key already exists then its value is overriden.
Parameters:
- Key: The key for a setting.
- Value: The value for a setting.
Writes a setting with specified key and value. If setting with that key already exists then its value is overriden.
Parameters:
- Key: The key for a setting.
- Value: The value for a setting.
Writes a setting with specified key and value. If setting with that key already exists then its value is overriden.
Parameters:
- Key: The key for a setting.
- Value: The value for a setting.
Keys
Gets a list of all keys stored in settings.
Default
Returns default instance of the class.
class method Default: UserSettings
static UserSettings Default()
static func Default() -> UserSettings
static UserSettings Default()
Shared Function Default() As UserSettings
Clear mapped
Removes all settings.
method Clear
void Clear()
func Clear()
void Clear()
Sub Clear()
Reads a setting with specified key. If setting with that key can not be found then specified default value is returned.
Parameters:
- Key: The key for a setting.
- DefaultValue: The default value for a setting.
Reads a setting with specified key. If setting with that key can not be found then specified default value is returned.
Parameters:
- Key: The key for a setting.
- DefaultValue: The default value for a setting.
Reads a setting with specified key. If setting with that key can not be found then specified default value is returned.
Parameters:
- Key: The key for a setting.
- DefaultValue: The default value for a setting.
Reads a setting with specified key. If setting with that key can not be found then specified default value is returned.
Parameters:
- Key: The key for a setting.
- DefaultValue: The default value for a setting.
Remove mapped
Removes a setting with a specified key.
method Remove(Key: String)
void Remove(String Key)
func Remove(_ Key: String)
void Remove(String Key)
Sub Remove(Key As String)
Parameters:
- Key: The key for a setting.
Save mapped
Causes any buffered data to be written to a settings storage.
method Save
void Save()
func Save()
void Save()
Sub Save()
Writes a setting with specified key and value. If setting with that key already exists then its value is overriden.
Parameters:
- Key: The key for a setting.
- Value: The value for a setting.
Writes a setting with specified key and value. If setting with that key already exists then its value is overriden.
Parameters:
- Key: The key for a setting.
- Value: The value for a setting.
Writes a setting with specified key and value. If setting with that key already exists then its value is overriden.
Parameters:
- Key: The key for a setting.
- Value: The value for a setting.
Writes a setting with specified key and value. If setting with that key already exists then its value is overriden.
Parameters:
- Key: The key for a setting.
- Value: The value for a setting.