diff --git a/Monorail/Monorail/FormMonorailCollection.cs b/Monorail/Monorail/FormMonorailCollection.cs index 4d0ee53..1cc0e1c 100644 --- a/Monorail/Monorail/FormMonorailCollection.cs +++ b/Monorail/Monorail/FormMonorailCollection.cs @@ -43,7 +43,7 @@ namespace Monorail listBoxStorages.Items.Clear(); for (int i = 0; i < _storage.Keys.Count; i++) { - listBoxStorages.Items.Add(_storage.Keys[i]); + listBoxStorages.Items.Add(_storage.Keys[i].Name); } if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count)) @@ -105,7 +105,7 @@ EventArgs e) "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - _storage.DelSet(listBoxStorages.SelectedItem.ToString() ?? string.Empty); + _storage.DelSet(name); ReloadObjects(); _logger.LogInformation($"Удален набор: {name}"); } diff --git a/Monorail/Monorail/Generics/MonorailsCollectionInfo.cs b/Monorail/Monorail/Generics/MonorailsCollectionInfo.cs index 3057e90..5457224 100644 --- a/Monorail/Monorail/Generics/MonorailsCollectionInfo.cs +++ b/Monorail/Monorail/Generics/MonorailsCollectionInfo.cs @@ -8,8 +8,8 @@ namespace Monorail.Generics { internal class MonorailsCollectionInfo : IEquatable { - public string Name { get; protected set; } - public string Description { get; protected set; } + public string Name { get; private set; } + public string Description { get; private set; } public MonorailsCollectionInfo(string name, string description) { Name = name; @@ -18,11 +18,16 @@ namespace Monorail.Generics public bool Equals(MonorailsCollectionInfo? other) { // TODO прописать логику сравнения по свойству Name - return Name == other.Name; + return Name == other?.Name; + throw new NotImplementedException(); } public override int GetHashCode() { - return this.Name.GetHashCode(); + return Name.GetHashCode(); + } + public override string ToString() + { + return "Object: " + Name; } } } diff --git a/Monorail/Monorail/Generics/MonorailsGenericStorage.cs b/Monorail/Monorail/Generics/MonorailsGenericStorage.cs index 43e556f..98a2089 100644 --- a/Monorail/Monorail/Generics/MonorailsGenericStorage.cs +++ b/Monorail/Monorail/Generics/MonorailsGenericStorage.cs @@ -33,6 +33,7 @@ namespace Monorail.Generics { MessageBox.Show("Словарь уже имеет объект с таким названием", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; } _monorailsStorages.Add(new MonorailsCollectionInfo(name, string.Empty), new MonorailsGenericCollection