chore 优化代码
This commit is contained in:
@ -12,7 +12,7 @@ namespace KonSoft.Admin.HttpApi.Client.ConsoleTestApp;
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(AdminHttpApiClientModule),
|
||||
typeof(AbpHttpClientIdentityModelModule)
|
||||
)]
|
||||
)]
|
||||
public class AdminConsoleApiClientModule : AbpModule
|
||||
{
|
||||
public override void PreConfigureServices(ServiceConfigurationContext context)
|
||||
@ -21,10 +21,10 @@ public class AdminConsoleApiClientModule : 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)))
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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.Admin.HttpApi.Client.ConsoleTestApp;
|
||||
@ -19,10 +19,10 @@ public class ConsoleTestAppHostedService : IHostedService
|
||||
public async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
using (var application = await AbpApplicationFactory.CreateAsync<AdminConsoleApiClientModule>(options =>
|
||||
{
|
||||
options.Services.ReplaceConfiguration(_configuration);
|
||||
options.UseAutofac();
|
||||
}))
|
||||
{
|
||||
options.Services.ReplaceConfiguration(_configuration);
|
||||
options.UseAutofac();
|
||||
}))
|
||||
{
|
||||
await application.InitializeAsync();
|
||||
|
||||
@ -37,4 +37,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.Admin.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>();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user