#if NETCOREAPP3_1
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using PaySharp.Core;
using PaySharp.Core.Utils;
namespace Microsoft.Extensions.DependencyInjection
{
public static class ServiceCollectionExtensions
{
///
/// 添加PaySharp
///
///
///
public static void AddPaySharp(this IServiceCollection services, Action setupAction)
{
services.AddSingleton();
services.AddScoped(a =>
{
var gateways = new Gateways();
setupAction(gateways);
return gateways;
});
}
///
/// 使用PaySharp
///
///
///
public static IApplicationBuilder UsePaySharp(this IApplicationBuilder app)
{
var httpContextAccessor = app.ApplicationServices.GetRequiredService();
HttpUtil.Configure(httpContextAccessor);
return app;
}
}
}
#endif