Skip to content

Commit 141f704

Browse files
committed
Use ValueTuple named values everywhere in WorkflowRegistry
1 parent 653fa00 commit 141f704

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/WorkflowCore/Services/WorkflowRegistry.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace WorkflowCore.Services
1111
public class WorkflowRegistry : IWorkflowRegistry
1212
{
1313
private readonly IServiceProvider _serviceProvider;
14-
private readonly BlockingCollection<(string workfloId, int version, WorkflowDefinition definition)> _registry = new BlockingCollection<(string, int, WorkflowDefinition)>();
14+
private readonly BlockingCollection<(string workflowId, int version, WorkflowDefinition definition)> _registry = new BlockingCollection<(string, int, WorkflowDefinition)>();
1515

1616
public WorkflowRegistry(IServiceProvider serviceProvider)
1717
{
@@ -23,11 +23,11 @@ public WorkflowDefinition GetDefinition(string workflowId, int? version = null)
2323
(string workflowId, int version, WorkflowDefinition definition) workflowEntry;
2424
if (version.HasValue)
2525
{
26-
workflowEntry = _registry.FirstOrDefault(x => x.Item1 == workflowId && x.Item2 == version.Value);
26+
workflowEntry = _registry.FirstOrDefault(x => x.workflowId == workflowId && x.version == version.Value);
2727
}
2828
else
2929
{
30-
workflowEntry = _registry.Where(x => x.Item1 == workflowId).OrderByDescending(x => x.Item2)
30+
workflowEntry = _registry.Where(x => x.workflowId == workflowId).OrderByDescending(x => x.version)
3131
.FirstOrDefault();
3232
}
3333

@@ -36,7 +36,7 @@ public WorkflowDefinition GetDefinition(string workflowId, int? version = null)
3636

3737
public void DeregisterWorkflow(string workflowId, int version)
3838
{
39-
var definition = _registry.FirstOrDefault(x => x.Item1 == workflowId && x.Item2 == version);
39+
var definition = _registry.FirstOrDefault(x => x.workflowId == workflowId && x.version == version);
4040
if (definition != default)
4141
{
4242
_registry.TryTake(out definition);
@@ -45,7 +45,7 @@ public void DeregisterWorkflow(string workflowId, int version)
4545

4646
public void RegisterWorkflow(IWorkflow workflow)
4747
{
48-
if (_registry.Any(x => x.Item1 == workflow.Id && x.Item2 == workflow.Version))
48+
if (_registry.Any(x => x.workflowId == workflow.Id && x.version == workflow.Version))
4949
{
5050
throw new InvalidOperationException($"Workflow {workflow.Id} version {workflow.Version} is already registered");
5151
}
@@ -58,7 +58,7 @@ public void RegisterWorkflow(IWorkflow workflow)
5858

5959
public void RegisterWorkflow(WorkflowDefinition definition)
6060
{
61-
if (_registry.Any(x => x.Item1 == definition.Id && x.Item2 == definition.Version))
61+
if (_registry.Any(x => x.workflowId == definition.Id && x.version == definition.Version))
6262
{
6363
throw new InvalidOperationException($"Workflow {definition.Id} version {definition.Version} is already registered");
6464
}
@@ -69,7 +69,7 @@ public void RegisterWorkflow(WorkflowDefinition definition)
6969
public void RegisterWorkflow<TData>(IWorkflow<TData> workflow)
7070
where TData : new()
7171
{
72-
if (_registry.Any(x => x.Item1 == workflow.Id && x.Item2 == workflow.Version))
72+
if (_registry.Any(x => x.workflowId == workflow.Id && x.version == workflow.Version))
7373
{
7474
throw new InvalidOperationException($"Workflow {workflow.Id} version {workflow.Version} is already registered");
7575
}
@@ -82,13 +82,13 @@ public void RegisterWorkflow<TData>(IWorkflow<TData> workflow)
8282

8383
public bool IsRegistered(string workflowId, int version)
8484
{
85-
var definition = _registry.FirstOrDefault(x => x.Item1 == workflowId && x.Item2 == version);
85+
var definition = _registry.FirstOrDefault(x => x.workflowId == workflowId && x.version == version);
8686
return definition != default;
8787
}
8888

8989
public IEnumerable<WorkflowDefinition> GetAllDefinitions()
9090
{
91-
return _registry.Select(i => i.Item3);
91+
return _registry.Select(i => i.definition);
9292
}
9393
}
9494
}

0 commit comments

Comments
 (0)