| | | 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.Runtime.ExceptionServices; |
| | | 5 | | using System.Threading; |
| | | 6 | | using System.Threading.Tasks; |
| | | 7 | | using CoreWCF.Runtime; |
| | | 8 | | using Microsoft.AspNetCore.Hosting.Server; |
| | | 9 | | using Microsoft.AspNetCore.Http.Features; |
| | | 10 | | |
| | | 11 | | namespace CoreWCF.Configuration |
| | | 12 | | { |
| | | 13 | | internal class WrappingIServer : IServer |
| | | 14 | | { |
| | | 15 | | private readonly ServiceBuilder _serviceBuilder; |
| | | 16 | | |
| | 513 | 17 | | public WrappingIServer(ServiceBuilder serviceBuilder) |
| | | 18 | | { |
| | 513 | 19 | | _serviceBuilder = serviceBuilder; |
| | 513 | 20 | | } |
| | | 21 | | |
| | 2002 | 22 | | public IFeatureCollection Features => InnerServer.Features; |
| | | 23 | | |
| | 4501 | 24 | | public IServer InnerServer { get; internal set; } |
| | | 25 | | |
| | | 26 | | public void Dispose() |
| | | 27 | | { |
| | 1022 | 28 | | InnerServer.Dispose(); |
| | 1022 | 29 | | } |
| | | 30 | | |
| | | 31 | | public async Task StartAsync<TContext>(IHttpApplication<TContext> application, CancellationToken cancellationTok |
| | | 32 | | { |
| | 512 | 33 | | await InnerServer.StartAsync(application, cancellationToken).ConfigureAwait(false); |
| | | 34 | | try |
| | | 35 | | { |
| | 512 | 36 | | await _serviceBuilder.OpenAsync(cancellationToken); |
| | 502 | 37 | | } |
| | 10 | 38 | | catch (CallbackException e) |
| | | 39 | | { |
| | 10 | 40 | | if (e.InnerException != null) |
| | | 41 | | { |
| | 10 | 42 | | ExceptionDispatchInfo.Capture(e.InnerException).Throw(); |
| | | 43 | | } |
| | | 44 | | |
| | 0 | 45 | | throw; |
| | | 46 | | } |
| | 502 | 47 | | } |
| | | 48 | | |
| | | 49 | | public Task StopAsync(CancellationToken cancellationToken) |
| | | 50 | | { |
| | 452 | 51 | | return InnerServer.StopAsync(cancellationToken); |
| | | 52 | | } |
| | | 53 | | } |
| | | 54 | | } |