private void ConfigureAlipay(IServiceCollection services) { var alipayOptions = Configuration.GetSection("Alipay").Get <AlipayOptions>(); //检查RSA私钥 AlipayConfigChecker.Check(alipayOptions.SignType, alipayOptions.PrivateKey); services.AddAlipay(options => options.SetOption(alipayOptions)).AddAlipayF2F(); }
/// <summary> /// /// </summary> /// <param name="services"></param> public void ConfigureServices(IServiceCollection services) { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); //ConfigureAlipay(services); // 注入MVC框架 services.AddMvc(options => { options.Filters.Add(typeof(ExceptionFilter)); }); services.AddDbContext <HainanContext>(options => options.UseSqlServer(Configuration.GetConnectionString("Connection_Hainan"))); services.AddDbContext <NewiBeaconContext>(options => options.UseSqlServer(Configuration.GetConnectionString("Connection_IbcSqlServer"))); services.AddDbContext <FunHaiNanContext>(options => options.UseMySql(Configuration.GetConnectionString("Connection_MySql")));; //配置跨域处理 services.AddCors(options => { options.AddPolicy("any", builder => { builder.AllowAnyOrigin() //允许任何来源的主机访问 .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials();//指定处理cookie }); }); var alipayOptions = Configuration.GetSection("Alipay_v1").Get <AlipayOptions>(); //检查RSA私钥 AlipayConfigChecker.Check(alipayOptions.SignType, alipayOptions.PrivateKey); services.AddAlipay(options => options.SetOption(alipayOptions)).AddAlipayF2F(); //配置Swagger services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Version = "v1", Title = "乐趣海南接口文档", Description = "RESTful API for TwBusManagement" //TermsOfService = "None", //Contact = new Contact { Name = "Alvin_Su", Email = "*****@*****.**", Url = "" } }); //Set the comments path for the swagger json and ui. var basePath = PlatformServices.Default.Application.ApplicationBasePath; var xmlPath = Path.Combine(basePath, "ZsqApp.Core.WebApi.xml"); c.IncludeXmlComments(xmlPath); // c.OperationFilter<HttpHeaderOperation>(); // 添加httpHeader参数 }); //IServiceContainer servicess = new ServiceContainer(); //servicess.AddType<IBiz, BizService>(); //读取配置信息 services.Configure <ZhangYuSetting>(this.Configuration.GetSection("Zhangyu")); services.Configure <RedisSettings>(this.Configuration.GetSection("Redis")); services.Configure <MongoSettings>(this.Configuration.GetSection("Mongo")); services.Configure <AliPaySetting>(this.Configuration.GetSection("Alipay")); services.Configure <ApplepaySetting>(this.Configuration.GetSection("Applepay")); services.Configure <OfPaySetting>(this.Configuration.GetSection("OfPay")); services.Configure <GameKeySetting>(this.Configuration.GetSection("GameKey")); services.Configure <CurrencyKeySetting>(this.Configuration.GetSection("CurrencyKey")); services.Configure <ValidateSetting>(this.Configuration.GetSection("ImgUrl")); services.Configure <PHPRequestSetting>(this.Configuration.GetSection("PHPRequests")); services.Configure <HaiXiaSetting>(this.Configuration.GetSection("HaiXiaSports")); services.Configure <HaiXiaPhpSetting>(this.Configuration.GetSection("HaiXiaPhpRequest")); services.Configure <StraitAliPaySetting>(this.Configuration.GetSection("StraitAlipay")); services.Configure <WeChatPaySetting>(this.Configuration.GetSection("WeChatPay")); services.Configure <LqhnWeChatPaySetting>(this.Configuration.GetSection("LqhnWeChatPay")); // 1.automapper注入 services.AddScoped <AutoMapper.IConfigurationProvider>(_ => AutoMapperConfig.GetMapperConfiguration()); services.AddScoped(_ => AutoMapperConfig.GetMapperConfiguration().CreateMapper()); //services.AddTransient<ISystems, Systems>(); //services.AddTransient<IRoutine, RoutineService>(); // 注册接口和实现类的映射关系 services.AddScoped <ILoggerService, LoggerService>(); services.AddScoped <ISystems, Systems>(); services.AddScoped <IUser, UserService>(); services.AddScoped <IPhoneMessage, PhoneMessageService>(); services.AddScoped <IToken, TokenService>(); services.AddScoped <IRoutine, RoutineService>(); services.AddScoped <IBiz, BizService>(); services.AddScoped <IRecharge, RechargeService>(); services.AddScoped <IGame, GameService>(); services.AddScoped <IUserTask, UserTaskService>(); services.AddScoped <IOfpay, OfPayService>(); services.AddScoped <IData, DataService>(); services.AddScoped <IChannel, ChannelService>(); services.AddScoped <IActivity, ActivityService>(); services.AddScoped <IAccout, AccoutService>(); services.AddScoped <IHomeService, HomeService>(); }