|
|
@@ -0,0 +1,41 @@ |
|
|
|
using Microsoft.AspNetCore.Hosting; |
|
|
|
using Microsoft.AspNetCore.Server.Kestrel.Core; |
|
|
|
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; |
|
|
|
using Microsoft.Extensions.Hosting; |
|
|
|
using Microsoft.Extensions.DependencyInjection.Abstractions; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Text; |
|
|
|
using Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets; |
|
|
|
using Microsoft.Extensions.DependencyInjection.Extensions; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.AspNetCore.Hosting.Server; |
|
|
|
|
|
|
|
namespace JT808.DotNetty |
|
|
|
{ |
|
|
|
public static class JT808WebHostBuilderKestrelExtensions |
|
|
|
{ |
|
|
|
/// <summary> |
|
|
|
/// Specify Kestrel as the server to be used by the web host. |
|
|
|
/// </summary> |
|
|
|
/// <param name="hostBuilder"> |
|
|
|
/// The Microsoft.AspNetCore.Hosting.IWebHostBuilder to configure. |
|
|
|
/// </param> |
|
|
|
/// <returns> |
|
|
|
/// The Microsoft.AspNetCore.Hosting.IWebHostBuilder. |
|
|
|
/// </returns> |
|
|
|
public static IHostBuilder UseKestrel(this IHostBuilder hostBuilder, Action<KestrelServerOptions> options) |
|
|
|
{ |
|
|
|
return hostBuilder.ConfigureServices((context,services) => |
|
|
|
{ |
|
|
|
services.Configure(options); |
|
|
|
// Don't override an already-configured transport |
|
|
|
services.TryAddSingleton<ITransportFactory, SocketTransportFactory>(); |
|
|
|
services.AddTransient<IConfigureOptions<KestrelServerOptions>, KestrelServerOptionsSetup>(); |
|
|
|
services.AddSingleton<IServer, KestrelServer>(); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |