From 992ae0d74b6f19dbae2cf63dc4c4e6f5ac6306eb Mon Sep 17 00:00:00 2001 From: bekodeg Date: Wed, 6 Dec 2023 10:42:21 +0400 Subject: [PATCH] =?UTF-8?q?7=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D1=84=D0=B8=D0=BD=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ElectricLocomotive/Generics/LocomotivesGenericStorage.cs | 2 +- ElectricLocomotive/Generics/SetGeneric.cs | 8 ++------ ElectricLocomotive/LogicFormLocomotiveCollection.cs | 8 ++++---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs b/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs index c270f19..d5faa52 100644 --- a/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs +++ b/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs @@ -158,7 +158,7 @@ namespace ProjectElectricLocomotive.Generics using (StreamReader sr = new(filename)) { string line; - if (!((line = sr.ReadLine() != null) && line.StartsWith("LocomotiveStorage"))) + if (!(((line = sr.ReadLine()) != null) && line.StartsWith("LocomotiveStorage"))) { //если нет такой записи, то это не те данные throw new ArgumentException("Неверный формат данных"); diff --git a/ElectricLocomotive/Generics/SetGeneric.cs b/ElectricLocomotive/Generics/SetGeneric.cs index 6cb07b4..fbaf54f 100644 --- a/ElectricLocomotive/Generics/SetGeneric.cs +++ b/ElectricLocomotive/Generics/SetGeneric.cs @@ -71,11 +71,7 @@ namespace ProjectElectricLocomotive.Generics /// public bool Remove(int position) { - if (position >= Count || position < 0) - { - return false; - } - if (_places[position] == null) + if (position >= Count || position < 0 || _places[position] == null) { throw new LocomotiveNotFoundException(position); } @@ -94,7 +90,7 @@ namespace ProjectElectricLocomotive.Generics { if (position >= Count || position < 0) { - return null; + throw new LocomotiveNotFoundException(position); } return _places[position]; } diff --git a/ElectricLocomotive/LogicFormLocomotiveCollection.cs b/ElectricLocomotive/LogicFormLocomotiveCollection.cs index 75ad021..ba3cb51 100644 --- a/ElectricLocomotive/LogicFormLocomotiveCollection.cs +++ b/ElectricLocomotive/LogicFormLocomotiveCollection.cs @@ -145,7 +145,7 @@ namespace ProjectElectricLocomotive catch (StorageOverflowException ex) { MessageBox.Show(ex.Message); - _logger.LogError(ex.ToString()); + _logger.LogWarning(ex.ToString()); } } @@ -197,7 +197,7 @@ namespace ProjectElectricLocomotive catch (LocomotiveNotFoundException ex) { MessageBox.Show(ex.Message); - _logger.LogError(ex.ToString()); + _logger.LogWarning(ex.ToString()); } } /// @@ -242,7 +242,7 @@ namespace ProjectElectricLocomotive MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); _logger.LogInformation($"Не удалось сохранить в {saveFileDialog.FileName}: {ex.Message}"); - _logger.LogDebug(ex.ToString()); + _logger.LogWarning(ex.ToString()); } } } @@ -267,7 +267,7 @@ namespace ProjectElectricLocomotive MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); _logger.LogInformation($"Не удалось загрузить из {openFileDialog.FileName}: {ex.Message}"); - _logger.LogDebug(ex.ToString()); + _logger.LogWarning(ex.ToString()); } } }