| | | 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.Collections.Generic; |
| | | 6 | | using System.Runtime.Versioning; |
| | | 7 | | |
| | | 8 | | namespace CoreWCF.Channels |
| | | 9 | | { |
| | | 10 | | [SupportedOSPlatform("windows")] |
| | | 11 | | public class NetNamedPipeOptions |
| | | 12 | | { |
| | 0 | 13 | | internal List<NamedPipeListenOptions> CodeBackedListenOptions { get; } = new List<NamedPipeListenOptions>(); |
| | 0 | 14 | | public IServiceProvider ApplicationServices { get; internal set; } |
| | | 15 | | |
| | 0 | 16 | | public void Listen(string baseAddress) => Listen(new Uri(baseAddress)); |
| | 0 | 17 | | public void Listen(Uri baseAddress) => Listen(baseAddress, _ => { }); |
| | | 18 | | |
| | 0 | 19 | | public void Listen(string baseAddress, Action<NamedPipeListenOptions> configure) => Listen(new Uri(baseAddress), |
| | | 20 | | public void Listen(Uri baseAddress, Action<NamedPipeListenOptions> configure) |
| | | 21 | | { |
| | 0 | 22 | | if (baseAddress == null) throw new ArgumentNullException(nameof(baseAddress)); |
| | 0 | 23 | | if (configure == null) throw new ArgumentNullException(nameof(configure)); |
| | | 24 | | |
| | 0 | 25 | | var listenOptions = new NamedPipeListenOptions(baseAddress); |
| | 0 | 26 | | ApplyEndpointDefaults(listenOptions); |
| | 0 | 27 | | configure(listenOptions); |
| | 0 | 28 | | CodeBackedListenOptions.Add(listenOptions); |
| | 0 | 29 | | } |
| | | 30 | | |
| | | 31 | | private void ApplyEndpointDefaults(NamedPipeListenOptions listenOptions) |
| | | 32 | | { |
| | 0 | 33 | | listenOptions.NetNamedPipeServerOptions = this; |
| | 0 | 34 | | } |
| | | 35 | | } |
| | | 36 | | } |