| | | 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; |
| | | 5 | | using System.Runtime.Versioning; |
| | | 6 | | using CoreWCF.Channels; |
| | | 7 | | using Microsoft.AspNetCore.Hosting; |
| | | 8 | | using Microsoft.Extensions.DependencyInjection; |
| | | 9 | | using Microsoft.Extensions.DependencyInjection.Extensions; |
| | | 10 | | using Microsoft.Extensions.Hosting; |
| | | 11 | | using Microsoft.Extensions.Options; |
| | | 12 | | |
| | | 13 | | namespace CoreWCF.Configuration |
| | | 14 | | { |
| | | 15 | | [SupportedOSPlatform("windows")] |
| | | 16 | | public static class NamedPipeIHostBuilderExtensions |
| | | 17 | | { |
| | | 18 | | public static IHostBuilder UseNetNamedPipe(this IHostBuilder hostBuilder) |
| | | 19 | | { |
| | 0 | 20 | | return hostBuilder.ConfigureServices((context, services) => |
| | 0 | 21 | | { |
| | 0 | 22 | | services.AddNetFramingServices(); |
| | 0 | 23 | | services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, NetNamedPipeHostedService>()); |
| | 0 | 24 | | services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<NetNamedPipeOptions>, NetNamedPi |
| | 0 | 25 | | }); |
| | | 26 | | } |
| | | 27 | | |
| | | 28 | | public static IHostBuilder UseNetNamedPipe(this IHostBuilder hostBuilder, Action<NetNamedPipeOptions> options) |
| | | 29 | | { |
| | 0 | 30 | | hostBuilder.UseNetNamedPipe().ConfigureNetNamedPipe(options); |
| | 0 | 31 | | return hostBuilder; |
| | | 32 | | } |
| | | 33 | | |
| | | 34 | | public static IHostBuilder ConfigureNetNamedPipe(this IHostBuilder hostBuilder, Action<NetNamedPipeOptions> opti |
| | | 35 | | { |
| | 0 | 36 | | return hostBuilder.ConfigureServices((context, services) => |
| | 0 | 37 | | { |
| | 0 | 38 | | services.TryAddEnumerable(ServiceDescriptor.Singleton<IConfigureOptions<NetNamedPipeOptions>, NetNamedPi |
| | 0 | 39 | | services.Configure(options); |
| | 0 | 40 | | }); |
| | | 41 | | } |
| | | 42 | | } |
| | | 43 | | } |