Правки с наборами

This commit is contained in:
DyCTaTOR 2023-12-17 20:37:47 +04:00
parent edd3626677
commit 73257bd563
3 changed files with 12 additions and 6 deletions

View File

@ -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}");
}

View File

@ -8,8 +8,8 @@ namespace Monorail.Generics
{
internal class MonorailsCollectionInfo : IEquatable<MonorailsCollectionInfo>
{
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;
}
}
}

View File

@ -33,6 +33,7 @@ namespace Monorail.Generics
{
MessageBox.Show("Словарь уже имеет объект с таким названием", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_monorailsStorages.Add(new MonorailsCollectionInfo(name, string.Empty),
new MonorailsGenericCollection<DrawningMonorail,