Skip to content

Commit e30782f

Browse files
committed
style: 格式化代码
1 parent 23f79aa commit e30782f

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

framework/src/Bing.AspNetCore/Bing/AspNetCore/AspNetCoreModule.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.ComponentModel;
3-
using Bing.AspNetCore.Security;
43
using Bing.AspNetCore.Security.Claims;
54
using Bing.Security.Claims;
65
using Microsoft.Extensions.DependencyInjection;

framework/src/Bing.AspNetCore/Bing/AspNetCore/Extensions/Extensions.ApplicationBuilder.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using Bing.AspNetCore.ExceptionHandling;
32
using Bing.AspNetCore.Logs;
43
using Bing.AspNetCore.RealIp;
54
using Microsoft.AspNetCore.Builder;
@@ -19,7 +18,6 @@ public static class BingApplicationBuilderExtensions
1918
/// <param name="builder">应用程序生成器</param>
2019
public static IApplicationBuilder UseRequestLog(this IApplicationBuilder builder) => builder.UseMiddleware<RequestLogMiddleware>();
2120

22-
2321
/// <summary>
2422
/// 注册真实IP中间件
2523
/// </summary>

framework/src/Bing.AspNetCore/Bing/AspNetCore/Extensions/Extensions.ServiceCollection.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,19 @@ public static class BingServiceCollectionExtensions
3838
public static void AddApiInterfaceService<TApiInterfaceService>(this IServiceCollection services) where TApiInterfaceService : class, IApiInterfaceService =>
3939
services.TryAddSingleton<IApiInterfaceService, TApiInterfaceService>();
4040

41+
#if NETCOREAPP3_0 || NETCOREAPP3_1 || NET5_0
42+
/// <summary>
43+
/// 获取<see cref="IWebHostEnvironment"/>环境信息
44+
/// </summary>
45+
/// <param name="services">服务集合</param>
46+
public static IWebHostEnvironment GetWebHostEnvironment(this IServiceCollection services) => services.GetSingletonInstance<IWebHostEnvironment>();
47+
#elif NETSTANDARD2_0
4148
/// <summary>
4249
/// 获取<see cref="IHostingEnvironment"/>环境信息
4350
/// </summary>
4451
/// <param name="services">服务集合</param>
4552
public static IHostingEnvironment GetHostingEnvironment(this IServiceCollection services) => services.GetSingletonInstance<IHostingEnvironment>();
53+
#endif
54+
4655
}
4756
}

framework/src/Bing.AspNetCore/Bing/AspNetCore/Tracing/AspNetCoreCorrelationIdProvider.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ public virtual string Get()
4848
{
4949
lock (HttpContextAccessor.HttpContext.Request.Headers)
5050
{
51-
if (correlationId.IsEmpty())
52-
{
53-
correlationId = CreateNewCorrelationId();
54-
HttpContextAccessor.HttpContext.Request.Headers[Options.HttpHeaderName] = correlationId;
55-
}
51+
if (!correlationId.IsEmpty())
52+
return correlationId;
53+
correlationId = CreateNewCorrelationId();
54+
HttpContextAccessor.HttpContext.Request.Headers[Options.HttpHeaderName] = correlationId;
5655
}
5756
}
5857

0 commit comments

Comments
 (0)