mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-12-30 02:14:44 +08:00
docs: 更新示例项目
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System.Reflection;
|
||||
using System.Web.Mvc;
|
||||
using Autofac;
|
||||
using Autofac.Integration.Mvc;
|
||||
using Autofac.Integration.WebApi;
|
||||
using Hangfire;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample
|
||||
{
|
||||
public class AutofacConfig
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
var builder = new ContainerBuilder();
|
||||
|
||||
builder.RegisterControllers(Assembly.GetExecutingAssembly());
|
||||
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
|
||||
builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()).AsImplementedInterfaces().AsSelf();
|
||||
|
||||
builder.RegisterType<Services.HttpClients.Implements.WechatTenpayCertificateManagerFactory>()
|
||||
.As<Services.HttpClients.IWechatTenpayCertificateManagerFactory>()
|
||||
.SingleInstance();
|
||||
builder.RegisterType<Services.HttpClients.Implements.WechatTenpayPublicKeyManagerFactory>()
|
||||
.As<Services.HttpClients.IWechatTenpayPublicKeyManagerFactory>()
|
||||
.SingleInstance();
|
||||
builder.RegisterType<Services.HttpClients.Implements.WechatTenpayClientFactory>()
|
||||
.As<Services.HttpClients.IWechatTenpayClientFactory>()
|
||||
.SingleInstance();
|
||||
|
||||
builder.RegisterType<Services.BackgroundJobs.TenpayCertificateRefreshingBackgroundJob>()
|
||||
.AsSelf()
|
||||
.InstancePerBackgroundJob();
|
||||
|
||||
var container = builder.Build();
|
||||
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
|
||||
System.Web.Http.GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample
|
||||
{
|
||||
public class FilterConfig
|
||||
{
|
||||
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
|
||||
{
|
||||
filters.Add(new HandleErrorAttribute());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Hangfire;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample
|
||||
{
|
||||
public class HangfireConfig
|
||||
{
|
||||
public static BackgroundJobServer Init()
|
||||
{
|
||||
GlobalConfiguration.Configuration
|
||||
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
|
||||
.UseSimpleAssemblyNameTypeSerializer()
|
||||
.UseRecommendedSerializerSettings()
|
||||
.UseInMemoryStorage();
|
||||
|
||||
var server = new BackgroundJobServer();
|
||||
|
||||
HangfireAspNet.Use(() => new BackgroundJobServer[] { server });
|
||||
|
||||
BackgroundJob.Enqueue<Services.BackgroundJobs.TenpayCertificateRefreshingBackgroundJob>(job => job.ExecuteAsync());
|
||||
RecurringJob.AddOrUpdate<Services.BackgroundJobs.TenpayCertificateRefreshingBackgroundJob>(job => job.ExecuteAsync(), Cron.Daily);
|
||||
|
||||
return server;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample
|
||||
{
|
||||
public class RouteConfig
|
||||
{
|
||||
public static void RegisterRoutes(RouteCollection routes)
|
||||
{
|
||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||
|
||||
routes.MapRoute(
|
||||
name: "Default",
|
||||
url: "{controller}/{action}/{id}",
|
||||
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Web.Http;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample
|
||||
{
|
||||
public static class WebApiConfig
|
||||
{
|
||||
public static void Register(HttpConfiguration config)
|
||||
{
|
||||
config.MapHttpAttributeRoutes();
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "Default",
|
||||
routeTemplate: "{controller}/{action}",
|
||||
defaults: new { }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user