Table of Contents

Class PersistentSettings

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

Base implementation of ISettings which can be loaded/saved from/to file. This is thread-safe class.

public abstract class PersistentSettings : ISettings
Inheritance
PersistentSettings
Implements
Inherited Members
Extension Methods

Constructors

PersistentSettings(ISettings, ISettingsSerializer)

Initialize new PersistentSettings instance.

protected PersistentSettings(ISettings template, ISettingsSerializer serializer)

Parameters

template ISettings

Template settings to initialize values.

serializer ISettingsSerializer

Settings serializer.

PersistentSettings(ISettingsSerializer)

Initialize new PersistentSettings instance.

protected PersistentSettings(ISettingsSerializer serializer)

Parameters

serializer ISettingsSerializer

Settings serializer.

Properties

Keys

Get all setting keys.

public IEnumerable<SettingKey> Keys { get; }

Property Value

IEnumerable<SettingKey>

Version

Get version of settings.

public abstract int Version { get; }

Property Value

int

Methods

GetRawValue(SettingKey)

Get raw value stored in settings no matter what type of value specified by key.

public object? GetRawValue(SettingKey key)

Parameters

key SettingKey

Key of setting.

Returns

object

Raw setting value.

Load(Stream)

Load settings from given stream synchronously.

public void Load(Stream stream)

Parameters

stream Stream

Stream to load settings from.

Load(string)

Load settings from file synchronously.

public void Load(string fileName)

Parameters

fileName string

Name of file to load settings from.

LoadAsync(Stream)

Load settings from given stream asynchronously.

public Task LoadAsync(Stream stream)

Parameters

stream Stream

Stream to load settings from.

Returns

Task

Task of asynchronous operation.

LoadAsync(string)

Load settings from file asynchronously.

public Task LoadAsync(string fileName)

Parameters

fileName string

Name of file to load settings from.

Returns

Task

Task of asynchronous operation.

OnUpgrade(int)

Called to upgrade settings.

protected abstract void OnUpgrade(int oldVersion)

Parameters

oldVersion int

Old version to upgrade from.

ResetValue(SettingKey)

Reset setting to default value.

public void ResetValue(SettingKey key)

Parameters

key SettingKey

Key of setting.

Save(Stream)

Save settings to given stream synchronously.

public void Save(Stream stream)

Parameters

stream Stream

Stream to save settings.

Save(string)

Save settings to file synchronously.

public void Save(string fileName)

Parameters

fileName string

Name of file to save settings.

SaveAsync(Stream)

Save settings to given stream asynchronously.

public Task SaveAsync(Stream stream)

Parameters

stream Stream

Stream to save settings.

Returns

Task

Task of asynchronous operation.

SaveAsync(string)

Save settings to file asynchronously.

public Task SaveAsync(string fileName)

Parameters

fileName string

Name of file to save settings.

Returns

Task

Task of asynchronous operation.

SetValue(SettingKey, object)

Set value of setting.

[Obsolete("Try using generic SetValue() instead, unless you don't know the type of value.")]
public void SetValue(SettingKey key, object value)

Parameters

key SettingKey

Key og setting.

value object

New value.

Events

SettingChanged

Raised after changing setting.

public event EventHandler<SettingChangedEventArgs>? SettingChanged

Event Type

EventHandler<SettingChangedEventArgs>

SettingChanging

Raised before changing setting.

public event EventHandler<SettingChangingEventArgs>? SettingChanging

Event Type

EventHandler<SettingChangingEventArgs>