Merged
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public class ConfigurationWriter<TConfiguration>(IConfigurationSource<TConfiguration> source) :
|
||||
public class ConfigurationWriter<TConfiguration>(IConfigurationSource<TConfiguration> source,
|
||||
IConfigurationFactory<TConfiguration> factory) :
|
||||
IConfigurationWriter<TConfiguration>
|
||||
where TConfiguration :
|
||||
class
|
||||
{
|
||||
public void Write(Action<TConfiguration> updateDelegate)
|
||||
{
|
||||
if (source.TryGet(out TConfiguration? value))
|
||||
if (!source.TryGet(out TConfiguration? value))
|
||||
{
|
||||
if (value is not null)
|
||||
{
|
||||
updateDelegate?.Invoke(value);
|
||||
Write(value);
|
||||
}
|
||||
value = (TConfiguration)factory.Create();
|
||||
}
|
||||
|
||||
if (value is not null)
|
||||
{
|
||||
updateDelegate?.Invoke(value);
|
||||
Write(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user