baseline: 小军 WMS 二开代码原始快照(含 SynOABusiness.cs Debugger.Break)
This commit is contained in:
commit
c2b0e7be0d
6522 files changed
+3530643
No files matched your search
@@ -0,0 +1,73 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Opsoft.NetCore.O3App.Domain;
|
||||
using Opsoft.NetCore.O3App.Shared;
|
||||
using System;
|
||||
|
||||
namespace Opsoft.NetCore.O3App.Infrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for the TraceIdMiddleware.
|
||||
/// </summary>
|
||||
public static class TraceIdExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Enables Trace IDs for the request.
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder UseTraceId(this IApplicationBuilder app)
|
||||
{
|
||||
if (app == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(app));
|
||||
}
|
||||
|
||||
return app.UseTraceId(new TraceIdOptions());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables Trace IDs for the request.
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <param name="header">The header field name to use for the Trace ID.</param>
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder UseTraceId(this IApplicationBuilder app, string header)
|
||||
{
|
||||
if (app == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(app));
|
||||
}
|
||||
|
||||
return app.UseTraceId(new TraceIdOptions
|
||||
{
|
||||
Header = header
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables Trace IDs for the request.
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder UseTraceId(this IApplicationBuilder app, TraceIdOptions options)
|
||||
{
|
||||
if (app == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(app));
|
||||
}
|
||||
|
||||
if (options == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
if (app.ApplicationServices.GetService(typeof(ITraceContextFactory)) == null)
|
||||
{
|
||||
throw new InvalidOperationException("Unable to find the required services. You must call the AddTraceId method in ConfigureServices in the application startup code.");
|
||||
}
|
||||
|
||||
return app.UseMiddleware<TraceIdMiddleware>(Microsoft.Extensions.Options.Options.Create(options));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user