@@ -95,9 +95,9 @@ public DurableTaskRegistry AddOrchestrator(TaskName name, Type type)
9595 {
9696 // TODO: Compile a constructor expression for performance.
9797 Check . ConcreteType < ITaskOrchestrator > ( type ) ;
98- return this . AddOrchestrator (
98+ return this . AddOrchestratorAllVersions (
9999 name ,
100- type . GetDurableTaskVersion ( ) ,
100+ type . GetDurableTaskVersions ( ) ,
101101 ( ) => ( ITaskOrchestrator ) Activator . CreateInstance ( type ) ) ;
102102 }
103103
@@ -109,7 +109,8 @@ public DurableTaskRegistry AddOrchestrator(TaskName name, Type type)
109109 public DurableTaskRegistry AddOrchestrator ( Type type )
110110 {
111111 Check . ConcreteType < ITaskOrchestrator > ( type ) ;
112- return this . AddOrchestrator ( type . GetTaskName ( ) , type . GetDurableTaskVersion ( ) , ( ) => ( ITaskOrchestrator ) Activator . CreateInstance ( type ) ) ;
112+ return this . AddOrchestratorAllVersions (
113+ type . GetTaskName ( ) , type . GetDurableTaskVersions ( ) , ( ) => ( ITaskOrchestrator ) Activator . CreateInstance ( type ) ) ;
113114 }
114115
115116 /// <summary>
@@ -140,7 +141,7 @@ public DurableTaskRegistry AddOrchestrator<TOrchestrator>()
140141 public DurableTaskRegistry AddOrchestrator ( TaskName name , ITaskOrchestrator orchestrator )
141142 {
142143 Check . NotNull ( orchestrator ) ;
143- return this . AddOrchestrator ( name , orchestrator . GetType ( ) . GetDurableTaskVersion ( ) , ( ) => orchestrator ) ;
144+ return this . AddOrchestratorAllVersions ( name , orchestrator . GetType ( ) . GetDurableTaskVersions ( ) , ( ) => orchestrator ) ;
144145 }
145146
146147 /// <summary>
@@ -151,9 +152,9 @@ public DurableTaskRegistry AddOrchestrator(TaskName name, ITaskOrchestrator orch
151152 public DurableTaskRegistry AddOrchestrator ( ITaskOrchestrator orchestrator )
152153 {
153154 Check . NotNull ( orchestrator ) ;
154- return this . AddOrchestrator (
155+ return this . AddOrchestratorAllVersions (
155156 orchestrator . GetType ( ) . GetTaskName ( ) ,
156- orchestrator . GetType ( ) . GetDurableTaskVersion ( ) ,
157+ orchestrator . GetType ( ) . GetDurableTaskVersions ( ) ,
157158 ( ) => orchestrator ) ;
158159 }
159160
@@ -302,4 +303,20 @@ public DurableTaskRegistry AddOrchestratorFunc(TaskName name, Action<TaskOrchest
302303 return CompletedNullTask ;
303304 } ) ;
304305 }
306+
307+ /// <summary>
308+ /// Registers an orchestrator factory under every supplied version. This is the shared fan-out used by the
309+ /// type- and singleton-based registration overloads so that a class declaring multiple versions via
310+ /// <see cref="DurableTaskAttribute.Version"/> is registered once per declared version.
311+ /// </summary>
312+ DurableTaskRegistry AddOrchestratorAllVersions (
313+ TaskName name , IReadOnlyList < TaskVersion > versions , Func < ITaskOrchestrator > factory )
314+ {
315+ foreach ( TaskVersion version in versions )
316+ {
317+ this . AddOrchestrator ( name , version , factory ) ;
318+ }
319+
320+ return this ;
321+ }
305322}
0 commit comments