Pibd-22_Lyakhov_T.I._Simple/StudentProgressRecord/Program.cs

65 lines
2.2 KiB
C#
Raw Normal View History

2024-11-18 14:55:50 +04:00
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Serilog;
2024-10-28 20:25:02 +04:00
2024-11-08 19:32:02 +04:00
using StudentProgressRecord.Forms;
2024-10-29 13:51:51 +04:00
using StudentProgressRecord.IRepositories;
2024-10-28 21:38:22 +04:00
using StudentProgressRecord.Repositories;
using StudentProgressRecord.RepositoryImp;
using Unity;
using Unity.Lifetime;
2024-11-18 14:55:50 +04:00
using Unity.Microsoft.Logging;
2024-10-28 21:38:22 +04:00
2024-10-28 17:55:57 +04:00
namespace StudentProgressRecord
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
2024-11-08 19:32:02 +04:00
Application.Run(CreateContainer().Resolve<FormUniversity>());
2024-10-28 21:38:22 +04:00
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
2024-11-18 14:55:50 +04:00
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
container.RegisterType<IConnectionString,ConnectionString>(new SingletonLifetimeManager());
2024-10-28 21:38:22 +04:00
container.RegisterType<IStatementRepository, StatementRepository>
(new TransientLifetimeManager());
container.RegisterType<IStudentRepository, StudentRepository>
(new TransientLifetimeManager());
container.RegisterType<ISubjectRepository, SubjectRepository>
(new TransientLifetimeManager());
container.RegisterType<ITeacherRepository, TeacherRepository>
(new TransientLifetimeManager());
2024-10-29 13:51:51 +04:00
container.RegisterType<IStudentTransitionRepository, StudentTransitionRepository>
(new TransientLifetimeManager());
2024-10-28 21:38:22 +04:00
return container;
2024-10-28 17:55:57 +04:00
}
2024-10-28 20:25:02 +04:00
2024-11-18 14:55:50 +04:00
private static LoggerFactory CreateLoggerFactory()
{
var lf = new LoggerFactory();
lf.AddSerilog(new LoggerConfiguration()
.ReadFrom.Configuration(new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsetting.json")
.Build())
.CreateLogger());
return lf;
}
2024-10-28 17:55:57 +04:00
}
}