35 lines
1.6 KiB
C#
35 lines
1.6 KiB
C#
|
|
using System;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using Sozsoft.Platform.Entities;
|
|||
|
|
using Microsoft.Extensions.Configuration;
|
|||
|
|
using Microsoft.Extensions.DependencyInjection;
|
|||
|
|
using Microsoft.Extensions.Hosting;
|
|||
|
|
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations;
|
|||
|
|
using Volo.Abp.Data;
|
|||
|
|
using Volo.Abp.DependencyInjection;
|
|||
|
|
using Volo.Abp.Domain.Entities;
|
|||
|
|
using Volo.Abp.Domain.Repositories;
|
|||
|
|
|
|||
|
|
namespace Sozsoft.Platform.Extensions;
|
|||
|
|
|
|||
|
|
public class PlatformApplicationConfigurationContributor : IApplicationConfigurationContributor, ITransientDependency
|
|||
|
|
{
|
|||
|
|
public async Task ContributeAsync(ApplicationConfigurationContributorContext context)
|
|||
|
|
{
|
|||
|
|
var hostEnvironment = context.ServiceProvider.GetRequiredService<IHostEnvironment>();
|
|||
|
|
context.ApplicationConfiguration.SetProperty("environment", hostEnvironment.EnvironmentName);
|
|||
|
|
|
|||
|
|
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
|
|||
|
|
context.ApplicationConfiguration.SetProperty("version", configuration.GetValue<string>("App:Version"));
|
|||
|
|
|
|||
|
|
var routeRepository = context.ServiceProvider.GetRequiredService<IRepository<Route, Guid>>();
|
|||
|
|
var items = await routeRepository.GetListAsync() ?? throw new EntityNotFoundException("RecordNotFound");
|
|||
|
|
context.ApplicationConfiguration.SetProperty("routes", items);
|
|||
|
|
|
|||
|
|
var customComponentRepository = context.ServiceProvider.GetRequiredService<IRepository<CustomComponent, Guid>>();
|
|||
|
|
var customComponents = await customComponentRepository.GetListAsync() ?? throw new EntityNotFoundException("RecordNotFound");
|
|||
|
|
context.ApplicationConfiguration.SetProperty("customComponents", customComponents);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|