Table of Contents

Class SettingsExtensions

Namespace
CarinaStudio.Configuration
Assembly
CarinaStudio.AppBase.Configuration.dll

Extensions for ISettings.

public static class SettingsExtensions
Inheritance
SettingsExtensions
Inherited Members

Methods

GetValueOrDefault(ISettings?, SettingKey)

Get setting value as type specified by key, or get default value.

[Obsolete("Try using generic GetValueOrDefault() instead, unless you don't know the type of value.")]
public static object GetValueOrDefault(this ISettings? settings, SettingKey key)

Parameters

settings ISettings

ISettings. The reference can be Null.

key SettingKey

Key of setting.

Returns

object

Setting value, or default value.

GetValueOrDefault<T>(ISettings?, SettingKey<T>)

Get setting value as type specified by key, or get default value.

public static T GetValueOrDefault<T>(this ISettings? settings, SettingKey<T> key)

Parameters

settings ISettings

ISettings. The reference can be Null.

key SettingKey<T>

Key of setting.

Returns

T

Setting value, or default value.

Type Parameters

T

Type of value.

IsFalse(ISettings, SettingKey<bool>)

Check whether the value is False or not.

public static bool IsFalse(this ISettings settings, SettingKey<bool> key)

Parameters

settings ISettings

ISettings.

key SettingKey<bool>

Key of setting.

Returns

bool

True if the value is False.

IsTrue(ISettings, SettingKey<bool>)

Check whether the value is True or not.

public static bool IsTrue(this ISettings settings, SettingKey<bool> key)

Parameters

settings ISettings

ISettings.

key SettingKey<bool>

Key of setting.

Returns

bool

True if the value is True.

ResetValues(ISettings)

Reset all values to default.

public static void ResetValues(this ISettings settings)

Parameters

settings ISettings

ISettings.

ResetValues(ISettings, IEnumerable<SettingKey>)

Reset specific set of values to default.

public static void ResetValues(this ISettings settings, IEnumerable<SettingKey> keys)

Parameters

settings ISettings

ISettings.

keys IEnumerable<SettingKey>

Key of settings to reset.

SetValue<T>(ISettings, SettingKey<T>, T)

Set value of setting.

public static void SetValue<T>(this ISettings settings, SettingKey<T> key, T value)

Parameters

settings ISettings

ISettings.

key SettingKey<T>

Key of setting.

value T

New value.

Type Parameters

T

Type of value.

ToggleValue(ISettings, SettingKey<bool>)

Toggle the boolean value.

public static bool ToggleValue(this ISettings settings, SettingKey<bool> key)

Parameters

settings ISettings

ISettings.

key SettingKey<bool>

Key of setting.

Returns

bool

Toggled value.

ValuesEqual(ISettings, ISettings)

Check whether values in two ISettings are same or not.

public static bool ValuesEqual(this ISettings settings, ISettings another)

Parameters

settings ISettings

ISettings.

another ISettings

Another ISettings.

Returns

bool

VerifyValue(ISettings, SettingKey)

Check whether type of value of given setting is correct or not. You can get raw value by calling GetRawValue(SettingKey) if type is incorrect.

public static bool VerifyValue(this ISettings settings, SettingKey key)

Parameters

settings ISettings

ISettings.

key SettingKey

Key of setting.

Returns

bool

True if type of value of given setting is correct.