private static IHostBuilder CreateHostBuilder(string[] args) { return(new ServiceComponentsHostBuilder() .UseDefault( new[] { typeof(TestCommand).Assembly }, new[] { typeof(TestCommandHandler).Assembly }) .ConfigureApp((configuration, environment, app) => { if (environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMiddleware <ErrorHandlingMiddleware>(); app.UseCors(builder => { builder.AllowAnyOrigin(); builder.AllowAnyHeader(); builder.AllowAnyMethod(); }); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); }) // Add endpoints .AddEndpoints() // Use serilog for logging .UseSerilog((context, log) => log .WriteTo.Console(LogEventLevel.Information) .WriteTo.Seq("http://*****:*****@localhost:5672", "test2", "test-queue", "test-exchange", retryIntervals: new[] { 1000, 3000, 5000 }) .AddRabbit("amqp://*****:*****@localhost:5672", "test2", "test-queue", "test-exchange") .ConfigureMvc(builder => builder.AddNewtonsoftJson(options => { options.UseCamelCasing(true); options.SerializerSettings.Converters.Add(new StringEnumConverter()); })) .AddRedisDistributedCache("localhost") .ConfigureContainer((context, builder) => { builder.AddRequestConstraints(request => request switch { LongCommand longCommand => new[] { "test1", "test2" }, TestCommand testCommand => new[] { "test2" }, _ => default }, (key, count) => (key, count) switch { ("test1", _)when count > 0 => false, ("test2", _)when count > 0 => false, (_, _) => true }, (key) => TimeSpan.FromSeconds(30));
public AddCommandPageViewModel(INavigationService navigationService) { Navigation = navigationService; EffectOn = true; EffectColor = Color.FromHex("#FFFF00"); IsExecutedCommand = false; IsExecutedLong = false; EnableRipple = true; TestParam = "Hoge"; TestLongParam = "LongHoge"; EnableSound = true; SyncCanExecute = true; ToggleCanExecute.Subscribe(_ => { CanExecute.Value = !CanExecute.Value; }); IDisposable subCommand = null; ChangeCommand.Subscribe(_ => { if (EffectCommand != null) { subCommand?.Dispose(); EffectCommand = null; } else { EffectCommand = CanExecute.ToReactiveCommand(); subCommand = EffectCommand.Subscribe(ExecCommand); } OnPropertyChanged(() => this.EffectCommand); }); ChangeCommand.Execute(); IDisposable subLongCommand = null; ChangeLongCommand.Subscribe(_ => { if (LongCommand != null) { subLongCommand.Dispose(); LongCommand = null; } else { LongCommand = CanExecute.ToReactiveCommand(); subLongCommand = LongCommand.Subscribe(ExecLongCommand); } OnPropertyChanged(() => this.LongCommand); }); ChangeLongCommand.Execute(); CanExecuteNullToggle.Subscribe(_ => { if (CanExecuteCommand != null) { CanExecuteCommand = null; CommandParameterText = "Command is null"; } else { CanExecuteCommand = CanExecute.ToAsyncReactiveCommand(); CanExecuteCommand.Subscribe(async x => { CommandParameterText = "Done Command"; await Task.Delay(500); }); } OnPropertyChanged(() => CanExecuteCommand); }); CanExecuteLongNullToggle.Subscribe(_ => { if (CanExecuteLongCommand != null) { CanExecuteLongCommand = null; CommandParameterText = "LongCommand is null"; } else { CanExecuteLongCommand = CanExecuteLong.ToReactiveCommand(); CanExecuteLongCommand.Subscribe(async x => { CommandParameterText = "Done Long Command"; await Task.Delay(500); }); } OnPropertyChanged(() => CanExecuteLongCommand); }); CanExecuteNullToggle.Execute(); CanExecuteLongNullToggle.Execute(); }