2025-02-06 16:58:13 +01:00
|
|
|
|
using Autofac;
|
|
|
|
|
|
using Core.Configurations;
|
|
|
|
|
|
using Core.Configurations.JsonConfigProvider;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace SetupInfrastructure
|
|
|
|
|
|
{
|
2025-02-06 23:46:55 +01:00
|
|
|
|
public class Startup
|
|
|
|
|
|
{
|
|
|
|
|
|
public virtual IConfigurationRoot Configuration()
|
|
|
|
|
|
{
|
|
|
|
|
|
var configuration = new ConfigurationBuilder()
|
|
|
|
|
|
.AddJsonFile("appconfiguration.dev.json")
|
|
|
|
|
|
.Build();
|
2025-02-06 16:58:13 +01:00
|
|
|
|
|
2025-02-06 23:46:55 +01:00
|
|
|
|
return configuration;
|
|
|
|
|
|
}
|
2025-02-06 16:58:13 +01:00
|
|
|
|
|
2025-02-06 23:46:55 +01:00
|
|
|
|
public IContainer ConfigureContainer(ConnectionStringTemplateParameters ctp)
|
|
|
|
|
|
{
|
|
|
|
|
|
var builder = new ContainerBuilder();
|
|
|
|
|
|
var configuration = Configuration();
|
2025-02-06 16:58:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
2025-02-06 23:46:55 +01:00
|
|
|
|
builder.RegisterModule(new Core.ModuleRegistry.DbPostgreSqlModule
|
|
|
|
|
|
{
|
|
|
|
|
|
ConnectionString = configuration.GetConnectionString("DefaultConnection").Replace("{usr}", ctp.user).Replace("{pwd}", ctp.pwd)
|
|
|
|
|
|
});
|
2025-02-06 16:58:13 +01:00
|
|
|
|
|
2025-02-06 23:46:55 +01:00
|
|
|
|
builder.RegisterModule(new Core.ModuleRegistry.TelemetryModule
|
|
|
|
|
|
{
|
|
|
|
|
|
TelemetryConfig = configuration.GetSection("ApplicationInsights").ToObject<Core.ModuleRegistry.TelemetryConfig>()
|
|
|
|
|
|
});
|
2025-02-06 16:58:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
2025-02-06 23:46:55 +01:00
|
|
|
|
return builder.Build();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public record ConnectionStringTemplateParameters(string user, string pwd);
|
|
|
|
|
|
}
|
2025-02-06 16:58:13 +01:00
|
|
|
|
}
|