diff --git a/AntiAircraftGun/AntiAircraftGun/AntiAircraftGun.csproj b/AntiAircraftGun/AntiAircraftGun/AntiAircraftGun.csproj
index 13ee123..3eb1f1d 100644
--- a/AntiAircraftGun/AntiAircraftGun/AntiAircraftGun.csproj
+++ b/AntiAircraftGun/AntiAircraftGun/AntiAircraftGun.csproj
@@ -8,6 +8,24 @@
enable
+
+
+
+
+
+
+ Always
+
+
+
+
+
+
+
+
+
+
+
True
diff --git a/AntiAircraftGun/AntiAircraftGun/FormMapWithSetAntiAircraftGuns.cs b/AntiAircraftGun/AntiAircraftGun/FormMapWithSetAntiAircraftGuns.cs
index 428b465..417275c 100644
--- a/AntiAircraftGun/AntiAircraftGun/FormMapWithSetAntiAircraftGuns.cs
+++ b/AntiAircraftGun/AntiAircraftGun/FormMapWithSetAntiAircraftGuns.cs
@@ -1,4 +1,5 @@
-using System;
+using Microsoft.Extensions.Logging;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -24,11 +25,16 @@ namespace AntiAircraftGun
/// Объект от коллекции карт
///
private readonly MapsCollection _mapsCollection;
+ ///
+ /// Логер
+ ///
+ private readonly ILogger _logger;
/// Конструктор
///
- public FormMapWithSetAntiAircraftGuns()
+ public FormMapWithSetAntiAircraftGuns(ILogger logger)
{
InitializeComponent();
+ _logger = logger;
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
comboBoxSelectorMap.Items.Clear();
foreach (var elem in _mapsDict)
@@ -75,6 +81,7 @@ namespace AntiAircraftGun
}
_mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]);
ReloadMaps();
+ _logger.LogInformation($"Добавлена карта {textBoxNewMapName.Text}");
}
///
/// Выбор карты
diff --git a/AntiAircraftGun/AntiAircraftGun/Program.cs b/AntiAircraftGun/AntiAircraftGun/Program.cs
index ce76065..f03c116 100644
--- a/AntiAircraftGun/AntiAircraftGun/Program.cs
+++ b/AntiAircraftGun/AntiAircraftGun/Program.cs
@@ -1,3 +1,7 @@
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+
namespace AntiAircraftGun
{
internal static class Program
@@ -11,7 +15,21 @@ namespace AntiAircraftGun
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new FormMapWithSetAntiAircraftGuns());
+ var services = new ServiceCollection();
+ ConfigureServices(services);
+ using (ServiceProvider serviceProvider = services.BuildServiceProvider())
+ {
+ Application.Run(serviceProvider.GetRequiredService());
+ }
+ }
+ private static void ConfigureServices(ServiceCollection services)
+ {
+ services.AddSingleton()
+ .AddLogging(option =>
+ {
+ option.SetMinimumLevel(LogLevel.Information);
+ option.AddNLog("nlog.config");
+ });
}
}
}
\ No newline at end of file
diff --git a/AntiAircraftGun/AntiAircraftGun/nlog.config b/AntiAircraftGun/AntiAircraftGun/nlog.config
new file mode 100644
index 0000000..6d5e25e
--- /dev/null
+++ b/AntiAircraftGun/AntiAircraftGun/nlog.config
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file