#region ========================================================================= USING ===================================================================================== using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using System.IO; using System.Reflection; #endregion namespace Lumina.Presentation.Api.Common.DependencyInjection; /// /// Class containing the configuration bindings of the Presentation API layer. /// internal static class PresentationApiLayerConfiguration { #region ================================================================== METHODS =================================================================================== /// /// Extension method for adding the Presentation API layer configuration to the DI container. /// /// The to add the configuration to. /// The configuration manager to use for the configuration. /// The updated . /// Thrown when the base path where the configuration files should be located, does not exist. public static IServiceCollection BindPresentationApiLayerConfiguration(this IServiceCollection services, IConfigurationManager configuration) { string? basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (!Directory.Exists(basePath)) throw new DirectoryNotFoundException($"The base path '{basePath}' does not exist."); configuration.SetBasePath(basePath); configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); configuration.AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true); return services; } #endregion }