| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System.Collections.Generic; |
| | | 5 | | using CoreWCF.Channels; |
| | | 6 | | using CoreWCF.Channels.Framing; |
| | | 7 | | using Microsoft.Extensions.DependencyInjection; |
| | | 8 | | using Microsoft.Extensions.DependencyInjection.Extensions; |
| | | 9 | | |
| | | 10 | | namespace CoreWCF.Configuration |
| | | 11 | | { |
| | | 12 | | public static class NetFramingServiceCollectionExtensions |
| | | 13 | | { |
| | | 14 | | public static IServiceCollection AddNetFramingServices(this IServiceCollection services) |
| | | 15 | | { |
| | 83 | 16 | | services.TryAddSingleton<NetMessageFramingConnectionHandler>(); |
| | 83 | 17 | | services.TryAddSingleton(NetMessageFramingConnectionHandler.BuildAddressTable); |
| | | 18 | | // NetNamedPipeHostedService.StartAsync needs to trigger building the address table, but the |
| | | 19 | | // UriPrefixTable type that exists in NetFramingBase is internal, so we also register it as |
| | | 20 | | // its implemented interface type as an alias to be able to resolve it. |
| | 83 | 21 | | services.TryAddSingleton<IEnumerable<KeyValuePair<BaseUriWithWildcard, HandshakeDelegate>>>(services => |
| | 83 | 22 | | services.GetRequiredService<UriPrefixTable<HandshakeDelegate>>()); |
| | 83 | 23 | | services.TryAddTransient<IFramingConnectionHandshakeBuilder, FramingConnectionHandshakeBuilder>(); |
| | 83 | 24 | | return services; |
| | | 25 | | } |
| | | 26 | | } |
| | | 27 | | } |