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(); context.ApplicationConfiguration.SetProperty("environment", hostEnvironment.EnvironmentName); var configuration = context.ServiceProvider.GetRequiredService(); context.ApplicationConfiguration.SetProperty("version", configuration.GetValue("App:Version")); var routeRepository = context.ServiceProvider.GetRequiredService>(); var items = await routeRepository.GetListAsync() ?? throw new EntityNotFoundException("RecordNotFound"); context.ApplicationConfiguration.SetProperty("routes", items); var customComponentRepository = context.ServiceProvider.GetRequiredService>(); var customComponents = await customComponentRepository.GetListAsync() ?? throw new EntityNotFoundException("RecordNotFound"); context.ApplicationConfiguration.SetProperty("customComponents", customComponents); } }