State sets default value if get doesn't find it

Which allows for normal usage of Dictionaries inside state....
This commit is contained in:
tomy2105 2021-06-23 16:04:55 +02:00
parent 0351f2360e
commit 3f862f4137

View file

@ -16,8 +16,16 @@ namespace Elsa
{
var item = state?.ContainsKey(key) == true ? state![key] : default;
if (item == null)
return defaultValue();
if (item == null)
{
if (state != null)
{
state.SetState(key, defaultValue());
item = state![key];
}
else
return defaultValue();
}
return item.ConvertTo<T>()!;
}