2024-11-16 14:06:34 +04:00
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.Logging;
|
2024-11-02 12:36:04 +04:00
|
|
|
using ProjectFamilyBudget.Repositories;
|
|
|
|
using ProjectFamilyBudget.Repositories.Implementations;
|
2024-11-16 14:06:34 +04:00
|
|
|
using Serilog;
|
2024-11-02 12:36:04 +04:00
|
|
|
using Unity;
|
2024-11-16 14:06:34 +04:00
|
|
|
using Unity.Microsoft.Logging;
|
2024-11-02 12:36:04 +04:00
|
|
|
|
2024-10-26 11:20:51 +04:00
|
|
|
namespace ProjectFamilyBudget
|
|
|
|
{
|
|
|
|
internal static class Program
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The main entry point for the application.
|
|
|
|
/// </summary>
|
|
|
|
[STAThread]
|
|
|
|
static void Main()
|
|
|
|
{
|
|
|
|
// To customize application configuration such as set high DPI settings or default font,
|
|
|
|
// see https://aka.ms/applicationconfiguration.
|
|
|
|
ApplicationConfiguration.Initialize();
|
2024-11-02 12:36:04 +04:00
|
|
|
Application.Run(CreateContainer().Resolve<FormFamilyBudget>());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private static IUnityContainer CreateContainer()
|
|
|
|
{
|
|
|
|
var container = new UnityContainer();
|
2024-11-16 14:06:34 +04:00
|
|
|
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
|
|
|
|
|
|
|
container.RegisterType<IPeople, PeopleRepository>();
|
|
|
|
container.RegisterType<IIncome, IncomeRepository>();
|
|
|
|
container.RegisterType<IExpense, ExpenseRepository>();
|
|
|
|
container.RegisterType<IPeopleIncome, PeopleIncomeRepository>();
|
|
|
|
container.RegisterType<IPeopleExpense, PeopleExpenseRepository>();
|
|
|
|
|
|
|
|
container.RegisterType<IConnectionString, ConnectionString>();
|
|
|
|
|
2024-11-02 12:36:04 +04:00
|
|
|
|
|
|
|
return container;
|
2024-10-26 11:20:51 +04:00
|
|
|
}
|
2024-11-16 14:06:34 +04:00
|
|
|
private static LoggerFactory CreateLoggerFactory()
|
|
|
|
{
|
|
|
|
var loggerFactory = new LoggerFactory();
|
|
|
|
loggerFactory.AddSerilog(new LoggerConfiguration()
|
|
|
|
.ReadFrom.Configuration(new ConfigurationBuilder()
|
|
|
|
.SetBasePath(Directory.GetCurrentDirectory())
|
|
|
|
.AddJsonFile("appsettings.json")
|
|
|
|
.Build())
|
|
|
|
.CreateLogger());
|
|
|
|
return loggerFactory;
|
|
|
|
}
|
2024-10-26 11:20:51 +04:00
|
|
|
}
|
|
|
|
}
|