@@ -201,24 +201,6 @@ protected Executor(string id, ExecutorOptions? options = null, bool declareCross
201201 /// RouteBuilder.</remarks>
202202 /// <returns>An instance of <see cref="ExecutorProtocol"/> that represents the fully configured protocol.</returns>
203203 protected abstract ProtocolBuilder ConfigureProtocol ( ProtocolBuilder protocolBuilder ) ;
204- //{
205- // // TODO: Eventually we want this to be the primary way to configure the protocol, but for now
206- // // we will drive it from the RouteBuilder for backward compatibility.
207- // this.ConfigureRoutes(protocolBuilder.RouteBuilder);
208-
209- // // Avoid re-entrancy issues. TODO: Remove old ConfigureXYZ calls once this is the primary configuration path.
210- // //this._configuringProtocol = true;
211- // //protocolBuilder.SendsMessageTypes(this.ConfigureSentTypes());
212- // //protocolBuilder.YieldsOutputTypes(this.ConfigureYieldTypes());
213- // //this._configuringProtocol = false;
214-
215- // return protocolBuilder;
216- //}
217-
218- /// <summary>
219- /// Override this method to register handlers for the executor.
220- /// </summary>
221- //protected virtual RouteBuilder ConfigureRoutes(RouteBuilder routeBuilder) => routeBuilder;
222204
223205 internal void AttachRequestContext ( IExternalRequestContext externalRequestContext )
224206 {
@@ -228,9 +210,6 @@ internal void AttachRequestContext(IExternalRequestContext externalRequestContex
228210 // .AttachRequestContext()
229211 // >>> only usable now
230212
231- // This can be removed once we can obsolete the old RegisterRoutes/RegisterXYZTypes methods in favour of the ConfigureProtocol
232- // method. Then instead of relying on the Executor instance to drive routing through .MessageRouter, the execution environment
233- // will rely on the Protocol instance directly.
234213 this . DelayedPortRegistrations . ApplyPortRegistrations ( externalRequestContext ) ;
235214 _ = this . Protocol ; // Force protocol to be built if not already done.
236215 }
@@ -245,34 +224,6 @@ internal void AttachRequestContext(IExternalRequestContext externalRequestContex
245224 protected internal virtual ValueTask InitializeAsync ( IWorkflowContext context , CancellationToken cancellationToken = default )
246225 => default ;
247226
248- ///// <summary>
249- ///// Override this method to declare the types of messages this executor can send.
250- ///// </summary>
251- ///// <returns></returns>
252- //protected virtual ISet<Type> ConfigureSentTypes()
253- //{
254- // if (this.Options.AutoSendMessageHandlerResultObject && !this._configuringProtocol)
255- // {
256- // return this.Router.DefaultOutputTypes;
257- // }
258-
259- // return new HashSet<Type>();
260- //}
261-
262- ///// <summary>
263- ///// Override this method to declare the types of messages this executor can yield as workflow outputs.
264- ///// </summary>
265- ///// <returns></returns>
266- //protected virtual ISet<Type> ConfigureYieldTypes()
267- //{
268- // if (this.Options.AutoYieldOutputHandlerResultObject && !this._configuringProtocol)
269- // {
270- // return this.Router.DefaultOutputTypes;
271- // }
272-
273- // return new HashSet<Type>();
274- //}
275-
276227 internal MessageRouter Router => this . Protocol . Router ;
277228
278229 /// <summary>
@@ -387,8 +338,6 @@ protected internal virtual ValueTask InitializeAsync(IWorkflowContext context, C
387338 /// <returns></returns>
388339 public bool CanHandle ( Type messageType ) => this . Protocol . CanHandle ( messageType ) ;
389340
390- //internal bool CanHandle(TypeId messageType) => this.Protocol.CanHandle(messageType);
391-
392341 internal bool CanOutput ( Type messageType ) => this . Protocol . CanOutput ( messageType ) ;
393342}
394343
@@ -404,7 +353,12 @@ public abstract class Executor<TInput>(string id, ExecutorOptions? options = nul
404353{
405354 /// <inheritdoc/>
406355 protected override ProtocolBuilder ConfigureProtocol ( ProtocolBuilder protocolBuilder )
407- => protocolBuilder . ConfigureRoutes ( routeBuilder => routeBuilder . AddHandler < TInput > ( this . HandleAsync ) ) ;
356+ {
357+ Func < TInput , IWorkflowContext , CancellationToken , ValueTask > handlerDelegate = this . HandleAsync ;
358+
359+ return protocolBuilder . ConfigureRoutes ( routeBuilder => routeBuilder . AddHandler ( handlerDelegate ) )
360+ . AddHandlerAttributeTypes ( handlerDelegate . Method ) ;
361+ }
408362
409363 /// <inheritdoc/>
410364 public abstract ValueTask HandleAsync ( TInput message , IWorkflowContext context , CancellationToken cancellationToken = default ) ;
@@ -424,7 +378,12 @@ public abstract class Executor<TInput, TOutput>(string id, ExecutorOptions? opti
424378{
425379 /// <inheritdoc/>
426380 protected override ProtocolBuilder ConfigureProtocol ( ProtocolBuilder protocolBuilder )
427- => protocolBuilder . ConfigureRoutes ( routeBuilder => routeBuilder . AddHandler < TInput , TOutput > ( this . HandleAsync ) ) ;
381+ {
382+ Func < TInput , IWorkflowContext , CancellationToken , ValueTask < TOutput > > handlerDelegate = this . HandleAsync ;
383+
384+ return protocolBuilder . ConfigureRoutes ( routeBuilder => routeBuilder . AddHandler ( handlerDelegate ) )
385+ . AddHandlerAttributeTypes ( handlerDelegate . Method ) ;
386+ }
428387
429388 /// <inheritdoc/>
430389 public abstract ValueTask < TOutput > HandleAsync ( TInput message , IWorkflowContext context , CancellationToken cancellationToken = default ) ;
0 commit comments