private static ITaskHubWorkerBuilder AddTaskHubWorkerCore(this IServiceCollection services) { services.AddLogging(); // This is added as a singleton implementation instance as we will fetch this out of the service collection // during subsequent calls to AddTaskHubWorker. var builder = new DefaultTaskHubWorkerBuilder(services); services.TryAddSingleton <ITaskHubWorkerBuilder>(builder); services.TryAddSingleton(sp => builder.Build(sp)); return(services.GetTaskHubBuilder()); }
/// <summary> /// Adds a <see cref="TaskHubWorker"/> and related services to the service collection. /// </summary> /// <param name="services">The service collection to add to.</param> /// <param name="configure">The action to configure the task hub builder with.</param> /// <returns>The original service collection, with services added.</returns> public static IServiceCollection AddTaskHubWorker( this IServiceCollection services, Action <ITaskHubWorkerBuilder> configure) { Check.NotNull(services, nameof(services)); Check.NotNull(configure, nameof(configure)); var builder = new DefaultTaskHubWorkerBuilder(services); configure(builder); services.TryAddSingleton(sp => builder.Build(sp)); return(services); }