1using CommunityToolkit.Mvvm.ComponentModel;
20 set => SetProperty(ref _key, value);
32 if (SetProperty(ref _value, value))
48 set =>
Value = (T)Convert.ChangeType(value, typeof(T));
51 private T _defaultValue;
60 if (SetProperty(ref _defaultValue, value))
73 private T _snapshotValue;
79 get => _snapshotValue;
82 if (SetProperty(ref _snapshotValue, value))
152 public WorkspaceSetting(
string key, T defaultValue, T minValue =
default, T maxValue =
default)
155 Value = defaultValue;
168 if (other ==
null) {
return; }
170 Value = (other.Value is ICloneable cloneableValue) ? (T)cloneableValue.Clone() : other.
Value;
171 DefaultValue = (other.DefaultValue is ICloneable cloneableDefaultValue) ? (T)cloneableDefaultValue.Clone() : other.
DefaultValue;
172 SnapshotValue = (other.SnapshotValue is ICloneable cloneableSnapshotValue) ? (T)cloneableSnapshotValue.Clone() : other.
SnapshotValue;
173 MinValue = (other.MinValue is ICloneable cloneableMinValue) ? (T)cloneableMinValue.Clone() : other.
MinValue;
174 MaxValue = (other.MaxValue is ICloneable cloneableMaxValue) ? (T)cloneableMaxValue.Clone() : other.
MaxValue;
181 #region Reset / Snapshot / Default
202 #region IEquatable, ICloneable, ToString()
204 public override bool Equals(
object obj)
208 => Equals((
object)other);
210 public override int GetHashCode()
211 =>
Value.GetHashCode();
213 public object Clone()
216 public override string ToString()
217 => $
"{Key}: {Value} (Default: {DefaultValue}, Snapshot: {SnapshotValue})";
T DefaultValue
Default value for the setting.
void CreateSnapshot()
Save the Value to the SnapshotValue
object UntypedMaxValue
Maximum value for the setting.
T MinValue
Minimum value for the setting.
object UntypedValue
Value for the setting.
T Value
Value for the setting.
bool HasDefaultValue
Indicating if the Value equals the DefaultValue.
Type ValueType
Type of this setting.
T MaxValue
Maximum value for the setting.
bool HasChanged
Indicating if the Value and SnapshotValue differ.
T SnapshotValue
Snapshot value for the setting.
void Reset()
Set the Value to the SnapshotValue
string Key
Key for this setting.
WorkspaceSetting()
Parameterless Constructor.
void SetToDefault()
Set the Value to the DefaultValue
WorkspaceSetting(string key, T defaultValue, T minValue=default, T maxValue=default)
Create a new WorkspaceSetting<T>
WorkspaceSetting(WorkspaceSetting< T > other)
Copy Constructor.
object UntypedMinValue
Minimum value for the setting.
object UntypedDefaultValue
Default value for the setting.
object UntypedSnapshotValue
Snapshot value for the setting.
Interface for a single workspace setting.