private static TaskHubClient ClientFactory(ITaskHubWorkerBuilder builder, IServiceProvider serviceProvider) { IOrchestrationServiceClient client = serviceProvider.GetService <IOrchestrationServiceClient>(); if (client is null) { #pragma warning disable CS0618 // Type or member is obsolete IOrchestrationService service = builder.OrchestrationService ?? serviceProvider.GetRequiredService <IOrchestrationService>(); #pragma warning restore CS0618 // Type or member is obsolete client = service as IOrchestrationServiceClient; if (client is null) { throw new InvalidOperationException( Strings.NotOrchestrationServiceClient(service.GetType())); } } ILoggerFactory loggerFactory = serviceProvider.GetRequiredService <ILoggerFactory>(); return(new TaskHubClient(client, loggerFactory: loggerFactory)); }