public App() { InitializeComponent(); MapsterConfig.Setup(); DependencyService.Get <INotificationManager>().Initialize(); CrossFirebasePushNotification.Current.Subscribe("global"); CrossFirebasePushNotification.Current.OnTokenRefresh += (s, p) => { System.Diagnostics.Debug.WriteLine($"TOKEN : {p.Token}"); }; CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) => { var notificationManager = DependencyService.Get <INotificationManager>(); if (p.Data.ContainsKey("message") && p.Data.ContainsKey("title")) { notificationManager.ScheduleNotification((string)p.Data["title"], (string)p.Data["message"]); } }; CrossFirebasePushNotification.Current.OnNotificationOpened += (s, p) => { System.Diagnostics.Debug.WriteLine("Opened"); foreach (var data in p.Data) { System.Diagnostics.Debug.WriteLine($"{data.Key} : {data.Value}"); } }; }
private async void Application_Startup(object sender, StartupEventArgs e) { DispatcherHelper.Initialize(); MapsterConfig.Configure(); #if DEBUG AllocConsole(); #endif Current.DispatcherUnhandledException += App_OnDispatcherUnhandledException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; bool createdNew = false; instanceMutex = new Mutex(true, "{4D4BF0F8-27FF-47DF-BC62-FA17DBE003D8}", out createdNew); if (createdNew) { #if ENABLE_AUTHORIZATION_CHECK Logger.Debug("RPARobot启动(带授权检测版本)……", logger); #else Logger.Debug("RPARobot启动(无授权检测版本)……", logger); #endif UiElement.Init(); initLocalRPAStudioDir(); initLogsDir(); initConfigDir(); JobScheduler = await QuartzHelper.InitSchedulerAsync(); await JobScheduler.Start(); } else { Environment.Exit(0); } }
public IMapperConfig <FROM, TO> Register <FROM, TO>() { MapsterConfig <FROM, TO> config = MapsterConfig <FROM, TO> .Instance; config.memberConfig = TypeAdapterConfig <FROM, TO> .NewConfig(); return(config); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); MapsterConfig.Config(); //Database.SetInitializer<ExchangeContext>(new DbInitializer()); }
public static IServiceCollection AddServices(this IServiceCollection services) { MapsterConfig.Configure(); return(services .AddScoped <IRateService, RateService>() .AddScoped <ITransactionService, TransactionService>() .AddScoped <IRateResolver, RateResolver>() .AddScoped <ICurrencyNormalizer, CurrencyNormalizer>()); }
public static IServiceCollection AddQuietStone(this IServiceCollection services, Action <QuietStoneConfig> config) { MapsterConfig.Configure(); return(services .Configure(config) .AddScoped <ITransactionDataProvider, QuietStone>() .AddScoped <IQuietStoneApi, QuietStoneApi>()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseDeveloperExceptionPage(); app.UseAuthentication(); app.UseDefaultFiles(); app.UseStaticFiles(); // Register the Swagger generator and the Swagger UI middlewares app.UseSwagger(settings => { new NSwag.SwaggerGeneration.SwaggerJsonSchemaGenerator(new NJsonSchema.Generation.JsonSchemaGeneratorSettings()); //settings.GeneratorSettings.DocumentProcessors.Add(new SecurityDefinitionAppender("apiKey", new NSwag.SwaggerSecurityScheme() //{ // Type = NSwag.SwaggerSecuritySchemeType.ApiKey, // Name = "Authorization", // In = NSwag.SwaggerSecurityApiKeyLocation.Header, // Description = "Bearer token" //})); }); app.UseSwaggerUi3(); app.UseCors("AllowAll"); app.UseCors("CorsPolicy"); app.UseHttpsRedirection(); app.UseSignalR(routes => { routes.MapHub <CenterHub>("/centerHub"); }); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); MapsterConfig map = new MapsterConfig(); map.Run(); new InitIdentity().CreateRoles(serviceProvider, Configuration).Wait(); app.UseHangfireServer(); app.UseHangfireDashboard(); }
public QuietStoneApiTests() { var opt = Options.Create(new QuietStoneConfig { BaseUrl = "http://quiet-stone-2094.herokuapp.com/", TransactionEndpoint = "/transactions.json", RatesEndpoint = "/rates.json" }); _quietStoneApi = new QuietStoneApi(opt); MapsterConfig.Configure(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); #region Swagger app.UseSwaggerUi3WithApiExplorer(settings => { settings.GeneratorSettings.DefaultPropertyNameHandling = PropertyNameHandling.CamelCase; settings.GeneratorSettings.Title = "HISOFT API"; //settings.GeneratorSettings.OperationProcessors.Add(new OperationSecurityScopeProcessor("Bearer")); //settings.GeneratorSettings.DocumentProcessors.Add(new SecurityDefinitionAppender("Bearer", // new SwaggerSecurityScheme // { // Type = SwaggerSecuritySchemeType.ApiKey, // Name = "Authorization", // Description = "Copy 'Bearer ' + valid JWT token into field", // In = SwaggerSecurityApiKeyLocation.Header // })); }); #endregion #region MapsterMapper MapsterConfig map = new MapsterConfig(); map.Run(); #endregion //app.UseHttpsRedirection(); app.UseMvc(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddDbContext <BankIssuerDbContext>(options => options.UseInMemoryDatabase("BankIssuer")); services.AddScoped(typeof(IRepository <>), typeof(Repository <>)); services.AddSingleton(MapsterConfig.GetConfiguredMappingConfig()); services.AddScoped <MapsterMapper.IMapper, MapsterMapper.Mapper>(); services.AddScoped <IBankIssuerMapper, BankIssuerMapper>(); services.AddTransient <Master>(); services.AddTransient <Visa>(); services.AddTransient <Func <Origin, ICalculator> >(serviceProvider => key => { return(key switch { Origin.MASTER => serviceProvider.GetService <Master>(), Origin.VISA => serviceProvider.GetService <Visa>(), _ => throw new KeyNotFoundException() }); });
public RateServiceTests() { var uowMock = new Mock <IUnitOfWork>(); uowMock.Setup(x => x.RateRepository.GetAll()) .Returns(new List <Rate> { new Rate { ID = "1", To = KnownCurrencies.USD, From = KnownCurrencies.CAD, ChangeRate = 23.5m }, new Rate { ID = "2", To = KnownCurrencies.UYU, From = KnownCurrencies.USD, ChangeRate = 44.00m }, new Rate { ID = "3", To = KnownCurrencies.CAD, From = KnownCurrencies.USD, ChangeRate = 10.5m } }.AsQueryable()); var transactionDataProviderMock = new Mock <ITransactionDataProvider>(); transactionDataProviderMock.Setup(x => x.GetRates()) .Returns(Task.Run(() => new List <Rate> { new Rate { To = KnownCurrencies.USD, From = KnownCurrencies.CAD, ChangeRate = 50.5m }, new Rate { To = KnownCurrencies.CAD, From = KnownCurrencies.USD, ChangeRate = 44.5m } })); _unitOfWork = uowMock.Object; _transactionDataProvider = transactionDataProviderMock; _logger = new Mock <ILogger <RateService> >().Object; MapsterConfig.Configure(); }
public TransactionServiceTests() { _x10CadTransaction = new Transaction { ID = "4", Currency = KnownCurrencies.CAD, Amount = 23m, Sku = "AX10" }; var x10UsdTransactionDto = new TransactionDto { ID = "1", Currency = KnownCurrencies.USD, Amount = 23.5m, Sku = "AX10" }; var uowMock = new Mock <IUnitOfWork>(); uowMock.Setup(x => x.TransactionRepository.GetAll()) .Returns(new List <Transaction> { new Transaction { ID = "1", Currency = KnownCurrencies.USD, Amount = 23.5m, Sku = "AX10" }, new Transaction { ID = "2", Currency = KnownCurrencies.UYU, Amount = 44.00m, Sku = "AX90" }, new Transaction { ID = "3", Currency = KnownCurrencies.CAD, Amount = 10.5m, Sku = "AX15" }, _x10CadTransaction }.AsQueryable()); var transactionDataProvider = new Mock <ITransactionDataProvider>(); transactionDataProvider.Setup(x => x.GetTransactions()) .Returns(Task.Run(() => new List <Transaction> { new Transaction { Currency = KnownCurrencies.USD, Sku = "J385X", Amount = 18m }, new Transaction { Currency = KnownCurrencies.CAD, Sku = "J385Y", Amount = 44.5m } })); var failingTransactionDataProvider = new Mock <ITransactionDataProvider>(); failingTransactionDataProvider.Setup(x => x.GetTransactions()) .Returns(Task.Run(() => { throw new GNBException("some fake message", ErrorCode.UnableToRetrieveTransactionsFromQuietStone); return(new List <Transaction>()); })); var normalizer = new Mock <ICurrencyNormalizer>(); normalizer.Setup(x => x.Normalize(KnownCurrencies.USD, It.IsAny <IEnumerable <TransactionDto> >())) .Returns(Task.Run(() => new List <TransactionDto> { new TransactionDto { ID = _x10CadTransaction.ID, Currency = KnownCurrencies.USD, Sku = _x10CadTransaction.Sku, Amount = _x10CadTransaction.Amount * CadToUsdRate }, x10UsdTransactionDto }.AsEnumerable())); _unitOfWork = uowMock.Object; _normalizer = normalizer.Object; _failingTransactionDataProvider = failingTransactionDataProvider.Object; _transactionDataProvider = transactionDataProvider.Object; _logger = new Mock <ILogger <TransactionService> >().Object; MapsterConfig.Configure(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, RoleManager <IdentityRole> roleManager, UserManager <MyUser> userManager, ITicketService _ticketService) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAuthentication(); app.UseStaticFiles(); #region Swagger app.UseSwaggerUi3WithApiExplorer(settings => { settings.GeneratorSettings.DefaultPropertyNameHandling = PropertyNameHandling.CamelCase; settings.GeneratorSettings.Title = "VAS API"; settings.GeneratorSettings.OperationProcessors.Add(new OperationSecurityScopeProcessor("Bearer")); settings.GeneratorSettings.DocumentProcessors.Add(new SecurityDefinitionAppender("Bearer", new SwaggerSecurityScheme { Type = SwaggerSecuritySchemeType.ApiKey, Name = "Authorization", Description = "Copy 'Bearer ' + valid JWT token into field", In = SwaggerSecurityApiKeyLocation.Header })); }); #endregion #region Identity var task = RolesExtenstions.InitAsync(roleManager, userManager); task.Wait(); #endregion #region MapsterMapper MapsterConfig map = new MapsterConfig(); map.Run(); #endregion #region Hangfire app.UseHangfireDashboard(); app.UseHangfireServer(); TestBackgroud background = new TestBackgroud(_ticketService); //BackgroundJob.Enqueue(() => background.ChangStatusOnTicket()); RecurringJob.AddOrUpdate(() => background.ChangeStatusOnTicket(), "0,30 7-23 * * *"); #endregion app.UseCors("AllowAll"); app.UseHttpsRedirection(); #region SignalR app.UseSignalR(r => { r.MapHub <CenterHub>("/centerHub"); }); #endregion app.UseMvc(); }