Skip to content

Commit

Permalink
Merge pull request #1167 from tomy2105/1145-CompositeActivityProperties
Browse files Browse the repository at this point in the history
State sets default value if get doesn't find it
  • Loading branch information
sfmskywalker committed Jun 23, 2021
2 parents ae7c57c + 3f862f4 commit fe96757
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/core/Elsa.Abstractions/Extensions/StateDictionaryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ public static T GetState<T>(this IDictionary<string, object?>? state, string key
{
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>()!;
}
Expand Down

0 comments on commit fe96757

Please sign in to comment.