chore 优化代码
This commit is contained in:
		| @ -22,4 +22,4 @@ public class ClientDemoService : ITransientDependency | ||||
|         Console.WriteLine($"Name     : {output.Name}"); | ||||
|         Console.WriteLine($"Surname  : {output.Surname}"); | ||||
|     } | ||||
| } | ||||
| } | ||||
| @ -1,8 +1,8 @@ | ||||
| using Microsoft.Extensions.Hosting; | ||||
| using System.Threading; | ||||
| using System.Threading.Tasks; | ||||
| using Microsoft.Extensions.Configuration; | ||||
| using Microsoft.Extensions.DependencyInjection; | ||||
| using Microsoft.Extensions.Hosting; | ||||
| using Volo.Abp; | ||||
|  | ||||
| namespace KonSoft.TenantManagement.HttpApi.Client.ConsoleTestApp; | ||||
| @ -18,11 +18,12 @@ public class ConsoleTestAppHostedService : IHostedService | ||||
|  | ||||
|     public async Task StartAsync(CancellationToken cancellationToken) | ||||
|     { | ||||
|         using (var application = await AbpApplicationFactory.CreateAsync<TenantManagementConsoleApiClientModule>(options => | ||||
|         { | ||||
|            options.Services.ReplaceConfiguration(_configuration); | ||||
|            options.UseAutofac(); | ||||
|         })) | ||||
|         using (var application = | ||||
|                await AbpApplicationFactory.CreateAsync<TenantManagementConsoleApiClientModule>(options => | ||||
|                { | ||||
|                    options.Services.ReplaceConfiguration(_configuration); | ||||
|                    options.UseAutofac(); | ||||
|                })) | ||||
|         { | ||||
|             await application.InitializeAsync(); | ||||
|  | ||||
| @ -37,4 +38,4 @@ public class ConsoleTestAppHostedService : IHostedService | ||||
|     { | ||||
|         return Task.CompletedTask; | ||||
|     } | ||||
| } | ||||
| } | ||||
| @ -1,22 +1,23 @@ | ||||
| using System.Threading.Tasks; | ||||
| using Microsoft.Extensions.Configuration; | ||||
| using Microsoft.Extensions.DependencyInjection; | ||||
| using Microsoft.Extensions.Hosting; | ||||
|  | ||||
| namespace KonSoft.TenantManagement.HttpApi.Client.ConsoleTestApp; | ||||
|  | ||||
| class Program | ||||
| internal class Program | ||||
| { | ||||
|     static async Task Main(string[] args) | ||||
|     private static async Task Main(string[] args) | ||||
|     { | ||||
|         await CreateHostBuilder(args).RunConsoleAsync(); | ||||
|     } | ||||
|  | ||||
|     public static IHostBuilder CreateHostBuilder(string[] args) => | ||||
|         Host.CreateDefaultBuilder(args) | ||||
|     public static IHostBuilder CreateHostBuilder(string[] args) | ||||
|     { | ||||
|         return Host.CreateDefaultBuilder(args) | ||||
|             .AddAppSettingsSecretsJson() | ||||
|             .ConfigureServices((hostContext, services) => | ||||
|             { | ||||
|                 services.AddHostedService<ConsoleTestAppHostedService>(); | ||||
|             }); | ||||
| } | ||||
|     } | ||||
| } | ||||
| @ -12,7 +12,7 @@ namespace KonSoft.TenantManagement.HttpApi.Client.ConsoleTestApp; | ||||
|     typeof(AbpAutofacModule), | ||||
|     typeof(TenantManagementHttpApiClientModule), | ||||
|     typeof(AbpHttpClientIdentityModelModule) | ||||
|     )] | ||||
| )] | ||||
| public class TenantManagementConsoleApiClientModule : AbpModule | ||||
| { | ||||
|     public override void PreConfigureServices(ServiceConfigurationContext context) | ||||
| @ -21,10 +21,10 @@ public class TenantManagementConsoleApiClientModule : AbpModule | ||||
|         { | ||||
|             options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) => | ||||
|             { | ||||
|                 clientBuilder.AddTransientHttpErrorPolicy( | ||||
|                     policyBuilder => policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i))) | ||||
|                 clientBuilder.AddTransientHttpErrorPolicy(policyBuilder => | ||||
|                     policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i))) | ||||
|                 ); | ||||
|             }); | ||||
|         }); | ||||
|     } | ||||
| } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user