mirror of
https://github.com/dotnetcore/Util.git
synced 2026-10-18 21:21:25 +08:00
46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.TestHost;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Util.Http;
|
|
using Xunit.DependencyInjection.Logging;
|
|
|
|
namespace Util.Localization;
|
|
|
|
/// <summary>
|
|
/// 启动配置
|
|
/// </summary>
|
|
public class Startup {
|
|
/// <summary>
|
|
/// 配置主机
|
|
/// </summary>
|
|
public void ConfigureHost( IHostBuilder hostBuilder ) {
|
|
hostBuilder.ConfigureDefaults( null )
|
|
.ConfigureWebHostDefaults( webHostBuilder => {
|
|
webHostBuilder.UseTestServer()
|
|
.Configure( t => {
|
|
t.UseRouting();
|
|
t.UseEndpoints( endpoints => {
|
|
endpoints.MapControllers();
|
|
} );
|
|
} );
|
|
} )
|
|
.AsBuild()
|
|
.AddJsonLocalization()
|
|
.AddUtil();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 配置服务
|
|
/// </summary>
|
|
public void ConfigureServices( IServiceCollection services ) {
|
|
services.AddLogging( logBuilder => logBuilder.AddXunitOutput() );
|
|
services.AddControllers();
|
|
services.AddTransient<IHttpClient>( t => {
|
|
var client = new HttpClientService();
|
|
client.SetHttpClient( t.GetService<IHost>().GetTestClient() );
|
|
return client;
|
|
} );
|
|
}
|
|
} |