From 3895ad8a7e39543488301fdb175692b2302cb630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B0=D0=BB=D0=B5=D1=80=D0=B8=D1=8F=20=D0=9D=D0=B8?= =?UTF-8?q?=D0=BA=D0=B8=D1=84=D0=BE=D1=80=D0=BE=D0=B2=D0=B0?= Date: Fri, 9 Dec 2022 18:44:57 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AccordionBus/AccordionBus/AbstractMap.cs | 13 ++++++------- AccordionBus/AccordionBus/FormMapWithSetBuses.cs | 5 +++++ AccordionBus/AccordionBus/SetBusesGeneric.cs | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/AccordionBus/AccordionBus/AbstractMap.cs b/AccordionBus/AccordionBus/AbstractMap.cs index 06068a2..494b6cd 100644 --- a/AccordionBus/AccordionBus/AbstractMap.cs +++ b/AccordionBus/AccordionBus/AbstractMap.cs @@ -165,24 +165,23 @@ namespace AccordionBus { return false; } - var otherMap = other as AbstractMap; - if (otherMap == null) + if (other == null) { return false; } - if (_width != otherMap._width) + if (_width != other._width) { return false; } - if (_height != otherMap._height) + if (_height != other._height) { return false; } - if (_size_x != otherMap._size_x) + if (_size_x != other._size_x) { return false; } - if (_size_y != otherMap._size_y) + if (_size_y != other._size_y) { return false; } @@ -190,7 +189,7 @@ namespace AccordionBus { for (int j = 0; j < _map.GetLength(1); j++) { - if (_map[i, j] != otherMap._map[i, j]) + if (_map[i, j] != other._map[i, j]) { return false; } diff --git a/AccordionBus/AccordionBus/FormMapWithSetBuses.cs b/AccordionBus/AccordionBus/FormMapWithSetBuses.cs index 4025ef7..e83a7dc 100644 --- a/AccordionBus/AccordionBus/FormMapWithSetBuses.cs +++ b/AccordionBus/AccordionBus/FormMapWithSetBuses.cs @@ -157,6 +157,11 @@ namespace AccordionBus _logger.LogWarning($"Ошибка переполнения хранилища: {ex.Message}"); MessageBox.Show($"Ошибка переполнения хранилища: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); } + catch (ArgumentException ex) + { + _logger.LogWarning($"Ошибка добавления: {ex.Message}"); + MessageBox.Show($"Ошибка добавления: {ex.Message}"); + } catch (Exception ex) { _logger.LogWarning($"Неизвестная ошибка: {ex.Message}"); diff --git a/AccordionBus/AccordionBus/SetBusesGeneric.cs b/AccordionBus/AccordionBus/SetBusesGeneric.cs index 5de6f7f..4e9cc11 100644 --- a/AccordionBus/AccordionBus/SetBusesGeneric.cs +++ b/AccordionBus/AccordionBus/SetBusesGeneric.cs @@ -52,7 +52,7 @@ namespace AccordionBus // Проверка на уникальность if (_places.Contains(bus)) { - return -1; + throw new ArgumentException("Объект с такими характеристиками уже существует в наборе."); } //проверка позиции if (Count == _maxCount)