From bfce6160f1be52dc6f1938fe4ac1a0d52a68640c Mon Sep 17 00:00:00 2001 From: SmallChi <564952747@qq.com> Date: Tue, 20 Nov 2018 23:30:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0http=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/JT808.DotNetty/JT808.DotNetty.csproj | 2 + .../JT808WebHostBuilderKestrelExtensions.cs | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/JT808.DotNetty/JT808WebHostBuilderKestrelExtensions.cs diff --git a/src/JT808.DotNetty/JT808.DotNetty.csproj b/src/JT808.DotNetty/JT808.DotNetty.csproj index d40f63f..608982c 100644 --- a/src/JT808.DotNetty/JT808.DotNetty.csproj +++ b/src/JT808.DotNetty/JT808.DotNetty.csproj @@ -10,6 +10,8 @@ + + diff --git a/src/JT808.DotNetty/JT808WebHostBuilderKestrelExtensions.cs b/src/JT808.DotNetty/JT808WebHostBuilderKestrelExtensions.cs new file mode 100644 index 0000000..dbcfc73 --- /dev/null +++ b/src/JT808.DotNetty/JT808WebHostBuilderKestrelExtensions.cs @@ -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 + { + /// + /// Specify Kestrel as the server to be used by the web host. + /// + /// + /// The Microsoft.AspNetCore.Hosting.IWebHostBuilder to configure. + /// + /// + /// The Microsoft.AspNetCore.Hosting.IWebHostBuilder. + /// + public static IHostBuilder UseKestrel(this IHostBuilder hostBuilder, Action options) + { + return hostBuilder.ConfigureServices((context,services) => + { + services.Configure(options); + // Don't override an already-configured transport + services.TryAddSingleton(); + services.AddTransient, KestrelServerOptionsSetup>(); + services.AddSingleton(); + }); + } + } +}