From 7009f2b1b7535826e351ef232ba181b9a0ebc449 Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Tue, 8 Nov 2022 00:28:17 +0400 Subject: [PATCH 1/4] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=B8=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B8=20=D0=B8=D1=85=20=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=BA=D0=B0,=20=D0=BD=D0=B5=D0=BC=D0=BD?= =?UTF-8?q?=D0=BE=D0=B3=D0=BE=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BE=D1=82=D1=80=D0=B8=D1=81=D0=BE=D0=B2=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=BE=D0=B2=20=D0=B2=20?= =?UTF-8?q?=D1=85=D1=80=D0=B0=D0=BD=D0=B8=D0=BB=D0=B8=D1=89=D0=B5=20=D0=B8?= =?UTF-8?q?=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20=D0=B8=D1=85=20=D1=85?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Locomotive/FormMapWithSetLocomotives.cs | 66 +++++++++++++------ .../Locomotive/LocomotiveNotFoundException.cs | 19 ++++++ .../MapWithSetLocomotivesGeneric.cs | 10 +-- Locomotive/Locomotive/MapsCollection.cs | 11 ++-- .../Locomotive/SetLocomotivesGeneric.cs | 20 +++--- .../Locomotive/StorageOverflowException.cs | 20 ++++++ 6 files changed, 103 insertions(+), 43 deletions(-) create mode 100644 Locomotive/Locomotive/LocomotiveNotFoundException.cs create mode 100644 Locomotive/Locomotive/StorageOverflowException.cs diff --git a/Locomotive/Locomotive/FormMapWithSetLocomotives.cs b/Locomotive/Locomotive/FormMapWithSetLocomotives.cs index 69b44ff..1e15a30 100644 --- a/Locomotive/Locomotive/FormMapWithSetLocomotives.cs +++ b/Locomotive/Locomotive/FormMapWithSetLocomotives.cs @@ -99,15 +99,26 @@ namespace Locomotive return; } - if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawningObjectLocomotive(locomotive) != -1) + try { - MessageBox.Show("Object added"); - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); - } + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawningObjectLocomotive(locomotive) != -1) + { + MessageBox.Show("Object added"); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } - else + else + { + MessageBox.Show("Failed to add object"); + } + } + catch(StorageOverflowException ex) { - MessageBox.Show("Failed to add object"); + MessageBox.Show($"Storage overflow error: {ex.Message}"); + } + catch (Exception ex) + { + MessageBox.Show($"Unknown error: {ex.Message}"); } } @@ -128,15 +139,27 @@ namespace Locomotive return; } int pos = Convert.ToInt32(maskedTextBoxPosition.Text); - if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null) + try { - MessageBox.Show("Object removed"); - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null) + { + MessageBox.Show("Object removed"); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + else + { + MessageBox.Show("Failed to remove object"); + } } - else + catch(LocomotiveNotFoundException ex) { - MessageBox.Show("Failed to remove object"); + MessageBox.Show($"Delete error: {ex.Message}"); } + catch (Exception ex) + { + MessageBox.Show($"Unknown error: {ex.Message}"); + } + } /// Вывод набора private void buttonShowStorage_Click(object sender, EventArgs e) @@ -190,13 +213,14 @@ namespace Locomotive { if (saveFileDialog.ShowDialog() == DialogResult.OK) { - if (_mapsCollection.SaveData(saveFileDialog.FileName)) + try { - MessageBox.Show("Saved successfully", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); + _mapsCollection.SaveData(saveFileDialog.FileName); + MessageBox.Show("Saving success", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); } - else + catch (Exception ex) { - MessageBox.Show("Saving failed", "Result", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"Saving error: {ex.Message}", "Result",MessageBoxButtons.OK, MessageBoxIcon.Error); } } } @@ -205,16 +229,18 @@ namespace Locomotive { if (loadFileDialog.ShowDialog() == DialogResult.OK) { - if (_mapsCollection.LoadData(loadFileDialog.FileName)) + + try { + _mapsCollection.LoadData(loadFileDialog.FileName); MessageBox.Show("Loaded successfully", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); + ReloadMaps(); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } - else + catch(Exception ex) { - MessageBox.Show("Loading failed", "Result", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"Loading failed + {ex.Message}", "Result", MessageBoxButtons.OK, MessageBoxIcon.Error); } - ReloadMaps(); - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } } } diff --git a/Locomotive/Locomotive/LocomotiveNotFoundException.cs b/Locomotive/Locomotive/LocomotiveNotFoundException.cs new file mode 100644 index 0000000..21333e6 --- /dev/null +++ b/Locomotive/Locomotive/LocomotiveNotFoundException.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Locomotive +{ + internal class LocomotiveNotFoundException : ApplicationException + { + public LocomotiveNotFoundException(int i) : base($"Не найден объект по позиции {i}") { } + public LocomotiveNotFoundException() : base() { } + public LocomotiveNotFoundException(string message) : base(message) { } + public LocomotiveNotFoundException(string message, Exception exception) : + base(message, exception) { } + protected LocomotiveNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } + } +} diff --git a/Locomotive/Locomotive/MapWithSetLocomotivesGeneric.cs b/Locomotive/Locomotive/MapWithSetLocomotivesGeneric.cs index f132ff7..f533023 100644 --- a/Locomotive/Locomotive/MapWithSetLocomotivesGeneric.cs +++ b/Locomotive/Locomotive/MapWithSetLocomotivesGeneric.cs @@ -15,9 +15,9 @@ namespace Locomotive /// Высота окна отрисовки private readonly int _pictureHeight; /// Размер занимаемого объектом места (ширина) - private readonly int _placeSizeWidth = 210; + private readonly int _placeSizeWidth = 150; /// Размер занимаемого объектом места (высота) - private readonly int _placeSizeHeight = 90; + private readonly int _placeSizeHeight = 150; /// Набор объектов private readonly SetLocomotivesGeneric _setLocomotives; /// Карта @@ -138,8 +138,8 @@ namespace Locomotive /// Метод прорисовки объектов private void DrawLocomotives(Graphics g) { - int width = _pictureWidth / _placeSizeWidth; - int height = _pictureHeight / _placeSizeHeight; + int width = _pictureWidth / _placeSizeWidth - 1; + int height = _pictureHeight / _placeSizeHeight - 1; int curWidth = 0; int curHeight = 0; @@ -147,7 +147,7 @@ namespace Locomotive foreach (var locomotive in _setLocomotives.GetLocomotives()) { // установка позиции - locomotive?.SetObject(curWidth * _placeSizeWidth + 10, curHeight * _placeSizeHeight + 15, _pictureWidth, _pictureHeight); + locomotive?.SetObject(curWidth * _placeSizeWidth + 10, curHeight * _placeSizeHeight + 80, _pictureWidth, _pictureHeight); locomotive?.DrawningObject(g); if (curWidth < width) curWidth++; else diff --git a/Locomotive/Locomotive/MapsCollection.cs b/Locomotive/Locomotive/MapsCollection.cs index a5cbd09..67427df 100644 --- a/Locomotive/Locomotive/MapsCollection.cs +++ b/Locomotive/Locomotive/MapsCollection.cs @@ -54,7 +54,7 @@ namespace Locomotive } /// Сохранение информации по локомотивам в хранилище в файл - public bool SaveData(string filename) + public void SaveData(string filename) { if (File.Exists(filename)) { @@ -72,14 +72,13 @@ namespace Locomotive ); } } - return true; } /// Загрузка нформации по локомотивам в депо из файла - public bool LoadData(string filename) + public void LoadData(string filename) { if (!File.Exists(filename)) { - return false; + throw new FileNotFoundException("Файл не найден"); } using (FileStream fs = new(filename, FileMode.Open)) using (StreamReader sr = new StreamReader(fs, Encoding.UTF8)) @@ -88,7 +87,7 @@ namespace Locomotive if (!curLine.Contains("MapsCollection")) { - return false; + throw new FileFormatException("Формат данных в файле неправильный"); } _mapStorages.Clear(); @@ -113,8 +112,6 @@ namespace Locomotive _mapStorages.Add(elems[0], new MapWithSetLocomotivesGeneric(_pictureWidth, _pictureHeight, map)); _mapStorages[elems[0]].LoadData(elems[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); } - - return true; } diff --git a/Locomotive/Locomotive/SetLocomotivesGeneric.cs b/Locomotive/Locomotive/SetLocomotivesGeneric.cs index 342fd46..53f8b6a 100644 --- a/Locomotive/Locomotive/SetLocomotivesGeneric.cs +++ b/Locomotive/Locomotive/SetLocomotivesGeneric.cs @@ -30,7 +30,8 @@ namespace Locomotive /// Добавление объекта в набор на конкретную позицию public int Insert(T locomotive, int position) { - if (position >= _maxCount|| position < 0) return -1; + if (position < 0) return -1; + if (Count >= _maxCount) throw new StorageOverflowException(_maxCount); _places.Insert(position, locomotive); return position; @@ -39,8 +40,9 @@ namespace Locomotive public T Remove(int position) { if (position >= _maxCount || position < 0) return null; + if (_places[position] is null) throw new LocomotiveNotFoundException(position); T result = _places[position]; - _places.RemoveAt(position); + _places[position] = null; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! РАНЬШЕ REMOVE return result; } // Индексатор @@ -61,15 +63,11 @@ namespace Locomotive public IEnumerable GetLocomotives() { foreach (var locomotive in _places) - { - if (locomotive != null) - { - yield return locomotive; - } - else - { - yield break; - } + { + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! РАНЬШЕ ВОЗВРАЩАЛОСЬ ТОЛЬКО ЕСЛИ НЕ НУЛЛ + + yield return locomotive; + } } } diff --git a/Locomotive/Locomotive/StorageOverflowException.cs b/Locomotive/Locomotive/StorageOverflowException.cs new file mode 100644 index 0000000..0aa497f --- /dev/null +++ b/Locomotive/Locomotive/StorageOverflowException.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Locomotive +{ + internal class StorageOverflowException : ApplicationException + { + public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: {count}") { } + public StorageOverflowException() : base() { } + public StorageOverflowException(string message) : base(message) { } + public StorageOverflowException(string message, Exception exception) : + base(message, exception) { } + protected StorageOverflowException(SerializationInfo info, StreamingContext context) : base(info, context) { } + + } +} -- 2.25.1 From 47dfc705d85f620844f7bde43ee80106901bb0f9 Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Tue, 8 Nov 2022 01:12:30 +0400 Subject: [PATCH 2/4] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BB=D0=BE=D0=B3=D0=B3=D0=B5=D1=80,=20=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BB=D0=BE=D1=81=D1=8C=20=D0=BF=D0=BE=D1=87=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D0=B8=D1=82=D1=8C=20=D0=BA=D0=BE=D0=B4=20=D0=B8=20?= =?UTF-8?q?=D1=83=D0=B1=D0=B5=D0=B4=D0=B8=D1=82=D1=8C=D1=81=D1=8F=20=D0=B2?= =?UTF-8?q?=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BE=D1=81=D0=BF=D0=BE=D1=81?= =?UTF-8?q?=D0=BE=D0=B1=D0=BD=D0=BE=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Locomotive/Locomotive/FormMapWithSetLocomotives.cs | 13 ++++++++++++- Locomotive/Locomotive/Locomotive.csproj | 7 +++++++ Locomotive/Locomotive/MapsCollection.cs | 5 ++++- Locomotive/Locomotive/Program.cs | 5 +++++ Locomotive/Locomotive/SetLocomotivesGeneric.cs | 14 +++++++++++--- 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/Locomotive/Locomotive/FormMapWithSetLocomotives.cs b/Locomotive/Locomotive/FormMapWithSetLocomotives.cs index 1e15a30..19b6790 100644 --- a/Locomotive/Locomotive/FormMapWithSetLocomotives.cs +++ b/Locomotive/Locomotive/FormMapWithSetLocomotives.cs @@ -1,4 +1,6 @@ -using System; +using Serilog; +using Serilog.Formatting.Compact; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -21,6 +23,8 @@ namespace Locomotive }; /// Объект от коллекции карт private readonly MapsCollection _mapsCollection; + + /// Конструктор public FormMapWithSetLocomotives() { @@ -64,12 +68,14 @@ namespace Locomotive return; } _mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]); + Log.Information($"Map {textBoxNewMapName.Text} added"); ReloadMaps(); } /// Выбор карты private void listBoxMaps_SelectedIndexChanged(object sender, EventArgs e) { pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + Log.Information($"Map switched to {listBoxMaps.SelectedItem?.ToString() ?? string.Empty}"); } /// Удаление карты private void buttonDeleteMap_Click(object sender, EventArgs e) @@ -81,6 +87,7 @@ namespace Locomotive if (MessageBox.Show($"Delete map {listBoxMaps.SelectedItem}?","Deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty); + Log.Information($"Map {listBoxMaps.SelectedItem?.ToString() ?? string.Empty} deleted"); ReloadMaps(); } } @@ -105,6 +112,7 @@ namespace Locomotive { MessageBox.Show("Object added"); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + Log.Information($"Locomotive {locomotive} added"); } else @@ -144,6 +152,7 @@ namespace Locomotive if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null) { MessageBox.Show("Object removed"); + Log.Information($"Locomotive at {pos} deleted"); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } else @@ -217,6 +226,7 @@ namespace Locomotive { _mapsCollection.SaveData(saveFileDialog.FileName); MessageBox.Show("Saving success", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); + Log.Information($"Saved to {saveFileDialog.FileName}"); } catch (Exception ex) { @@ -234,6 +244,7 @@ namespace Locomotive { _mapsCollection.LoadData(loadFileDialog.FileName); MessageBox.Show("Loaded successfully", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); + Log.Information($"Loaded from {loadFileDialog.FileName}"); ReloadMaps(); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } diff --git a/Locomotive/Locomotive/Locomotive.csproj b/Locomotive/Locomotive/Locomotive.csproj index 13ee123..4a08ebd 100644 --- a/Locomotive/Locomotive/Locomotive.csproj +++ b/Locomotive/Locomotive/Locomotive.csproj @@ -8,6 +8,13 @@ enable + + + + + + + True diff --git a/Locomotive/Locomotive/MapsCollection.cs b/Locomotive/Locomotive/MapsCollection.cs index 67427df..01faa30 100644 --- a/Locomotive/Locomotive/MapsCollection.cs +++ b/Locomotive/Locomotive/MapsCollection.cs @@ -1,4 +1,5 @@ -using System; +using Serilog; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -78,6 +79,7 @@ namespace Locomotive { if (!File.Exists(filename)) { + Log.Warning($"FileNotFoundException {filename}"); throw new FileNotFoundException("Файл не найден"); } using (FileStream fs = new(filename, FileMode.Open)) @@ -87,6 +89,7 @@ namespace Locomotive if (!curLine.Contains("MapsCollection")) { + Log.Warning($"FileFormatException"); throw new FileFormatException("Формат данных в файле неправильный"); } diff --git a/Locomotive/Locomotive/Program.cs b/Locomotive/Locomotive/Program.cs index ceb3e6a..50c16fd 100644 --- a/Locomotive/Locomotive/Program.cs +++ b/Locomotive/Locomotive/Program.cs @@ -1,3 +1,5 @@ +using Serilog; + namespace Locomotive { internal static class Program @@ -10,6 +12,9 @@ namespace Locomotive { // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. + + + Log.Logger = new LoggerConfiguration().WriteTo.File(new Serilog.Formatting.Compact.CompactJsonFormatter(), "C:\\secondCourse\\OOP\\log.clef").CreateLogger(); ApplicationConfiguration.Initialize(); Application.Run(new FormMapWithSetLocomotives()); } diff --git a/Locomotive/Locomotive/SetLocomotivesGeneric.cs b/Locomotive/Locomotive/SetLocomotivesGeneric.cs index 53f8b6a..2b6612a 100644 --- a/Locomotive/Locomotive/SetLocomotivesGeneric.cs +++ b/Locomotive/Locomotive/SetLocomotivesGeneric.cs @@ -1,4 +1,5 @@ -using System; +using Serilog; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -31,7 +32,10 @@ namespace Locomotive public int Insert(T locomotive, int position) { if (position < 0) return -1; - if (Count >= _maxCount) throw new StorageOverflowException(_maxCount); + if (Count >= _maxCount) { + Log.Warning("StorageOverflowException"); + throw new StorageOverflowException(_maxCount); + } _places.Insert(position, locomotive); return position; @@ -40,7 +44,11 @@ namespace Locomotive public T Remove(int position) { if (position >= _maxCount || position < 0) return null; - if (_places[position] is null) throw new LocomotiveNotFoundException(position); + if (_places[position] is null) + { + Log.Warning($"LocomotiveNotFoundException at {position}"); + throw new LocomotiveNotFoundException(position); + } T result = _places[position]; _places[position] = null; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! РАНЬШЕ REMOVE return result; -- 2.25.1 From 3f65961713e6f89900488d2e6892eb3e38524eeb Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Tue, 8 Nov 2022 16:15:06 +0400 Subject: [PATCH 3/4] =?UTF-8?q?=D0=A1=D0=B4=D0=B0=D0=BD=D0=B0=20=D0=BB?= =?UTF-8?q?=D0=B0=D0=B17,=20=D1=82=D1=80=D0=B5=D0=B1=D1=83=D0=B5=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D1=87=D0=B8=D1=81=D1=82=D0=BA=D0=B0=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Locomotive/Locomotive/FormMapWithSetLocomotives.cs | 2 +- Locomotive/Locomotive/Program.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Locomotive/Locomotive/FormMapWithSetLocomotives.cs b/Locomotive/Locomotive/FormMapWithSetLocomotives.cs index 19b6790..a4d16e9 100644 --- a/Locomotive/Locomotive/FormMapWithSetLocomotives.cs +++ b/Locomotive/Locomotive/FormMapWithSetLocomotives.cs @@ -112,7 +112,7 @@ namespace Locomotive { MessageBox.Show("Object added"); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); - Log.Information($"Locomotive {locomotive} added"); + Log.Information($"Object {locomotive} added"); } else diff --git a/Locomotive/Locomotive/Program.cs b/Locomotive/Locomotive/Program.cs index 50c16fd..3fee70d 100644 --- a/Locomotive/Locomotive/Program.cs +++ b/Locomotive/Locomotive/Program.cs @@ -14,7 +14,7 @@ namespace Locomotive // see https://aka.ms/applicationconfiguration. - Log.Logger = new LoggerConfiguration().WriteTo.File(new Serilog.Formatting.Compact.CompactJsonFormatter(), "C:\\secondCourse\\OOP\\log.clef").CreateLogger(); + Log.Logger = new LoggerConfiguration().WriteTo.File(new Serilog.Formatting.Compact.CompactJsonFormatter(), "C:\\secondCourse\\OOP\\ProjectLomotive\\Locomotive\\log.clef").CreateLogger(); ApplicationConfiguration.Initialize(); Application.Run(new FormMapWithSetLocomotives()); } -- 2.25.1 From 88b702d5b588a50c3a830eff01fc096a23d44323 Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Mon, 21 Nov 2022 17:06:04 +0400 Subject: [PATCH 4/4] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D0=B8=D1=89=D0=B5=D0=BD?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=B4=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Locomotive/Locomotive/SetLocomotivesGeneric.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Locomotive/Locomotive/SetLocomotivesGeneric.cs b/Locomotive/Locomotive/SetLocomotivesGeneric.cs index 2b6612a..104b027 100644 --- a/Locomotive/Locomotive/SetLocomotivesGeneric.cs +++ b/Locomotive/Locomotive/SetLocomotivesGeneric.cs @@ -50,7 +50,7 @@ namespace Locomotive throw new LocomotiveNotFoundException(position); } T result = _places[position]; - _places[position] = null; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! РАНЬШЕ REMOVE + _places[position] = null; return result; } // Индексатор @@ -72,8 +72,6 @@ namespace Locomotive { foreach (var locomotive in _places) { - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! РАНЬШЕ ВОЗВРАЩАЛОСЬ ТОЛЬКО ЕСЛИ НЕ НУЛЛ - yield return locomotive; } -- 2.25.1