From 03dfb3fb18cc48335dcfd4c7ced99c5ad57921a0 Mon Sep 17 00:00:00 2001 From: Pyro <732603@gmail.com> Date: Fri, 29 Nov 2024 09:16:11 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B5=D0=BE=D0=B1=D1=85=D0=BE?= =?UTF-8?q?=D0=B4=D0=B8=D0=BC=D1=8B=D1=85=20=D0=B7=D0=B0=D0=B2=D0=B8=D1=81?= =?UTF-8?q?=D0=B8=D0=BC=D0=BE=D1=81=D1=82=D0=B5=D0=B9=20=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=B0=20=D0=BB=D0=BE?= =?UTF-8?q?=D0=B3=D0=B3=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/IConnectionString.cs | 6 ++++++ .../appsettings.json | 15 +++++++++++++++ .../ProjectConfectioneryFactory/Program.cs | 18 ++++++++++++++++++ .../ProjectConfectioneryFactory.csproj | 17 +++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 ProjectConfectionaryFactory/ProjectConfectionaryFactory/Repositories/IConnectionString.cs create mode 100644 ProjectConfectionaryFactory/ProjectConfectionaryFactory/appsettings.json diff --git a/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Repositories/IConnectionString.cs b/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Repositories/IConnectionString.cs new file mode 100644 index 0000000..3a8ab9f --- /dev/null +++ b/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Repositories/IConnectionString.cs @@ -0,0 +1,6 @@ +namespace ProjectConfectionaryFactory.Repositories; + +public interface IConnectionString +{ + public string ConnectionString { get; } +} diff --git a/ProjectConfectionaryFactory/ProjectConfectionaryFactory/appsettings.json b/ProjectConfectionaryFactory/ProjectConfectionaryFactory/appsettings.json new file mode 100644 index 0000000..87b332f --- /dev/null +++ b/ProjectConfectionaryFactory/ProjectConfectionaryFactory/appsettings.json @@ -0,0 +1,15 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.File" ], + "MinimumLevel": "Debug", + "WriteTo": [ + { + "Name": "File", + "Args": { + "path": "Logs/confectionary_log.txt", + "rollingInterval": "Day" + } + } + ] + } +} \ No newline at end of file diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Program.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Program.cs index 41dc9af..aeaf713 100644 --- a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Program.cs +++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Program.cs @@ -22,13 +22,31 @@ namespace ProjectConfectioneryFactory private static IUnityContainer CreateContainer() { var container = new UnityContainer(); + + container.AddExtension(new LoggingExtension(CreateLoggerFactory())); + container.RegisterType(new TransientLifetimeManager()); container.RegisterType(new TransientLifetimeManager()); container.RegisterType(new TransientLifetimeManager()); container.RegisterType(new TransientLifetimeManager()); container.RegisterType(new TransientLifetimeManager()); container.RegisterType(new TransientLifetimeManager()); + + container.RegisterType(new SingletonLifetimeManager()); + return container; } + + 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; + } } } \ No newline at end of file diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/ProjectConfectioneryFactory.csproj b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/ProjectConfectioneryFactory.csproj index accbdf0..8fa1cd1 100644 --- a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/ProjectConfectioneryFactory.csproj +++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/ProjectConfectioneryFactory.csproj @@ -9,7 +9,18 @@ + + + + + + + + + + + @@ -27,4 +38,10 @@ + + + PreserveNewest + + + \ No newline at end of file