| | 1 | | // Copyright (c) ZeroC, Inc. |
| | 2 | |
|
| | 3 | | using IceRpc.Extensions.DependencyInjection.Internal; |
| | 4 | | using Microsoft.Extensions.DependencyInjection; |
| | 5 | |
|
| | 6 | | namespace IceRpc.Extensions.DependencyInjection; |
| | 7 | |
|
| | 8 | | /// <summary>Provides an extension method for <see cref="IServiceCollection" /> to add a dispatcher.</summary> |
| | 9 | | public static class DispatcherServiceCollectionExtensions |
| | 10 | | { |
| | 11 | | /// <summary>Adds an <see cref="IDispatcher" /> to this service collection.</summary> |
| | 12 | | /// <param name="services">The service collection to add services to.</param> |
| | 13 | | /// <param name="configure">The action to configure the new dispatcher.</param> |
| | 14 | | /// <returns>The service collection.</returns> |
| | 15 | | public static IServiceCollection AddIceRpcDispatcher( |
| | 16 | | this IServiceCollection services, |
| | 17 | | Action<IDispatcherBuilder> configure) => |
| 0 | 18 | | services.AddSingleton(provider => |
| 0 | 19 | | { |
| 0 | 20 | | var builder = new DispatcherBuilder(provider); |
| 0 | 21 | | configure(builder); |
| 0 | 22 | | return builder.Build(); |
| 0 | 23 | | }); |
| | 24 | | } |