workflow-core
workflow-core copied to clipboard
GetDefinition fails when no version is provided and workflowid is not registered yet
Hi all,
found a little bug when a concrete implementation is not registered yet and startworkflow is called without specific version:
I solved it for me with the following two lines in the registry:
if (!_registry.Any(x => x.Item1 == workflowId)) return null;
public WorkflowDefinition GetDefinition(string workflowId, int? version = null)
{
if (version.HasValue)
{
var entry = _registry.FirstOrDefault(x => x.Item1 == workflowId && x.Item2 == version.Value);
if (entry == null)
{
return null;
}
return entry.Item3;
}
else
{
if (!_registry.Any(x => x.Item1 == workflowId))
return null;
int maxVersion = _registry.Where(x => x.Item1 == workflowId).Max(x => x.Item2);
var entry = _registry.FirstOrDefault(x => x.Item1 == workflowId && x.Item2 == maxVersion);
if (entry == null)
{
return null;
}
return entry.Item3;
}
}
Regards,
d-metrics
😃 thanks Would you be willing to make a PR? I'd really like to get more code contributors on this project, I'm a huge bottle neck at the moment