1using CommunityToolkit.Mvvm.ComponentModel;
21 public List<IWorkspaceSetting>
Settings {
get;
set; } =
new List<IWorkspaceSetting>();
32 #region Setting management methods
48 if (
Settings.Where(s =>
string.Compare(s.Key, setting.
Key,
true) == 0).Any())
51 throw new ArgumentException($
"A setting with the key '{setting.Key}' already exists.", nameof(setting));
56 setting.PropertyChanged += (sender, e) =>
58 switch (e.PropertyName)
91 public WorkspaceSetting<T>
MakeSureSettingExists<T>(
string settingKey, T defaultValue, T minValue =
default, T maxValue =
default)
96 setting =
new WorkspaceSetting<T>(settingKey, defaultValue, minValue, maxValue);
101 setting.DefaultValue = defaultValue;
148 GroupKey = other.GroupKey;
151 if (setting is ICloneable cloneableSetting)
166 #region IEquatable, ICloneable
168 public override bool Equals(
object obj)
172 => Equals((
object)other);
174 public override int GetHashCode()
177 public object Clone()
A group of WorkspaceSetting<T> objects.
WorkspaceSettingsGroup()
Parameterless Constructor.
void AddSetting(IWorkspaceSetting setting)
Add a new IWorkspaceSetting
void Reset()
Reset all IWorkspaceSetting in Settings
string _groupKey
Key for this group.
List< IWorkspaceSetting > Settings
List with IWorkspaceSetting instances belonging to this group.
WorkspaceSettingsGroup(string groupKey)
Create a new instance and set the group key.
bool HasChanged
Indicating if any of the Settings has changed.
WorkspaceSetting< T > GetSetting< T >(string settingKey)
Get the setting with the requested key.
WorkspaceSettingsGroup(WorkspaceSettingsGroup other)
Copy Constructor.
void AddSetting< T >(WorkspaceSetting< T > setting)
Add a new WorkspaceSetting<T>
IWorkspaceSetting GetSetting(string settingKey)
Get the setting with the requested key.
WorkspaceSetting< T > MakeSureSettingExists< T >(string settingKey, T defaultValue, T minValue=default, T maxValue=default)
Try to get the WorkspaceSetting<T> with the requested key and add a new setting with the default valu...
Interface for a single workspace setting.
bool HasChanged
Indicating if the UntypedValue and UntypedSnapshotValue differ.
void Reset()
Set the UntypedValue to the UntypedSnapshotValue
string Key
Key for this setting.