Add foundation

This commit is contained in:
TheXamlGuy
2024-04-13 11:29:32 +01:00
parent 6f31aa8513
commit 053d8a851e
264 changed files with 3428 additions and 4683 deletions
+25
View File
@@ -0,0 +1,25 @@
namespace Toolkit.Foundation;
public class ConfigurationValue<TConfiguration, TValue>(Func<TConfiguration, Action<TValue>> changed)
where TValue :
class, new()
{
private TValue? currentValue;
public bool TryUpdate(TConfiguration configuration,
out TValue value)
{
TValue newValue = new();
changed(configuration).Invoke(newValue);
if (!EqualityComparer<TValue>.Default.Equals(currentValue, newValue))
{
value = newValue;
currentValue = newValue;
return true;
}
value = currentValue!;
return false;
}
}