41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
|
using Microsoft.Extensions.Hosting;
|
||
|
using System.Threading;
|
||
|
using System.Threading.Tasks;
|
||
|
using Microsoft.Extensions.Configuration;
|
||
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
using Volo.Abp;
|
||
|
|
||
|
namespace Sinet.Universal.Admin.HttpApi.Client.ConsoleTestApp;
|
||
|
|
||
|
public class ConsoleTestAppHostedService : IHostedService
|
||
|
{
|
||
|
private readonly IConfiguration _configuration;
|
||
|
|
||
|
public ConsoleTestAppHostedService(IConfiguration configuration)
|
||
|
{
|
||
|
_configuration = configuration;
|
||
|
}
|
||
|
|
||
|
public async Task StartAsync(CancellationToken cancellationToken)
|
||
|
{
|
||
|
using (var application = await AbpApplicationFactory.CreateAsync<AdminConsoleApiClientModule>(options =>
|
||
|
{
|
||
|
options.Services.ReplaceConfiguration(_configuration);
|
||
|
options.UseAutofac();
|
||
|
}))
|
||
|
{
|
||
|
await application.InitializeAsync();
|
||
|
|
||
|
var demo = application.ServiceProvider.GetRequiredService<ClientDemoService>();
|
||
|
await demo.RunAsync();
|
||
|
|
||
|
await application.ShutdownAsync();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public Task StopAsync(CancellationToken cancellationToken)
|
||
|
{
|
||
|
return Task.CompletedTask;
|
||
|
}
|
||
|
}
|