-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed the problems of multiple server hosting with minimum api
- Loading branch information
1 parent
1474647
commit 8b8aff9
Showing
3 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/SuperSocket.Server/Host/SuperSocketWebApplicationBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Diagnostics.Metrics; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace SuperSocket.Server.Host | ||
{ | ||
public class SuperSocketWebApplicationBuilder : IHostApplicationBuilder | ||
{ | ||
private readonly IHostApplicationBuilder _hostApplicationBuilder; | ||
|
||
public IDictionary<object, object> Properties => _hostApplicationBuilder.Properties; | ||
|
||
public IConfigurationManager Configuration => _hostApplicationBuilder.Configuration; | ||
|
||
public IHostEnvironment Environment => _hostApplicationBuilder.Environment; | ||
|
||
public ILoggingBuilder Logging => _hostApplicationBuilder.Logging; | ||
|
||
public IMetricsBuilder Metrics => _hostApplicationBuilder.Metrics; | ||
|
||
public IServiceCollection Services => _hostApplicationBuilder.Services; | ||
|
||
internal SuperSocketWebApplicationBuilder(IHostApplicationBuilder hostApplicationBuilder) | ||
{ | ||
_hostApplicationBuilder = hostApplicationBuilder; | ||
} | ||
|
||
public IHostBuilder Host | ||
{ | ||
get | ||
{ | ||
return _hostApplicationBuilder.GetType() | ||
.GetProperty("Host", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance) | ||
.GetValue(_hostApplicationBuilder) as IHostBuilder; | ||
} | ||
} | ||
|
||
public IHost Build() | ||
{ | ||
var host = _hostApplicationBuilder | ||
.GetType() | ||
.GetMethod(nameof(Build)) | ||
.Invoke(_hostApplicationBuilder, Array.Empty<object>()) as IHost; | ||
|
||
host.Services.GetService<MultipleServerHostBuilder>()?.AdaptMultipleServerHost(host.Services); | ||
|
||
return host; | ||
} | ||
|
||
void IHostApplicationBuilder.ConfigureContainer<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder> factory, Action<TContainerBuilder> configure) | ||
{ | ||
_hostApplicationBuilder.ConfigureContainer<TContainerBuilder>(factory, configure); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters