diff --git a/base/Catamaran/Catamaran/FormCatamaranCollection.cs b/base/Catamaran/Catamaran/FormCatamaranCollection.cs index 62d71ab..5dc3d63 100644 --- a/base/Catamaran/Catamaran/FormCatamaranCollection.cs +++ b/base/Catamaran/Catamaran/FormCatamaranCollection.cs @@ -106,6 +106,10 @@ namespace Catamaran MessageBox.Show(ex.Message); _logger.LogWarning($"{ex.Message} в наборе {listBoxStorages.SelectedItem.ToString()}"); } + catch (ArgumentException ex) + { + MessageBox.Show(ex.Message); + } } } /// diff --git a/base/Catamaran/Catamaran/SetGeneric.cs b/base/Catamaran/Catamaran/SetGeneric.cs index 5557eaa..c650640 100644 --- a/base/Catamaran/Catamaran/SetGeneric.cs +++ b/base/Catamaran/Catamaran/SetGeneric.cs @@ -43,9 +43,9 @@ namespace Catamaran.Generics /// /// Добавляемый катамаран /// - public bool Insert(T catamaran) + public bool Insert(T catamaran, IEqualityComparer? equal = null) { - return Insert(catamaran, 0); + return Insert(catamaran, 0, equal); } /// /// Добавление объекта в набор на конкретную позицию @@ -53,13 +53,16 @@ namespace Catamaran.Generics /// Добавляемая лодка /// Позиция /// - public bool Insert(T catamaran, int position) + public bool Insert(T catamaran, int position, IEqualityComparer? equal = null) { if (position < 0 || position >= _maxCount) throw new CatamaranNotFoundException(position); if (Count >= _maxCount) throw new StorageOverflowException(_maxCount); + + if (equal != null && _places.Contains(catamaran, equal)) + throw new ArgumentException("Данный объект уже есть в коллекции"); _places.Insert(0, catamaran); return true; }