diff --git a/ProjectStormtrooper/ProjectStormtrooper/PlanesCollectionInfo.cs b/ProjectStormtrooper/ProjectStormtrooper/PlanesCollectionInfo.cs new file mode 100644 index 0000000..c7d1f55 --- /dev/null +++ b/ProjectStormtrooper/ProjectStormtrooper/PlanesCollectionInfo.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectStormtrooper +{ + public class PlanesCollectionInfo : IEquatable + { + public string Name { get; private set; } + public string Description { get; private set; } + public PlanesCollectionInfo(string name, string description) + { + Name = name; + Description = description; + } + public bool Equals(PlanesCollectionInfo? other) + { + return Name.Equals(other.Name); + } + } +} diff --git a/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericStorage.cs b/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericStorage.cs index 3bf2e09..56d27dd 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericStorage.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericStorage.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml.Linq; namespace ProjectStormtrooper { @@ -23,11 +24,11 @@ namespace ProjectStormtrooper /// /// Словарь (хранилище) /// - readonly Dictionary> _planeStorages; + readonly Dictionary> _planeStorages; /// /// Возвращение списка названий наборов /// - public List Keys => _planeStorages.Keys.ToList(); + public List Keys => _planeStorages.Keys.ToList(); /// /// Ширина окна отрисовки /// @@ -43,7 +44,7 @@ namespace ProjectStormtrooper /// public PlanesGenericStorage(int pictureWidth, int pictureHeight) { - _planeStorages = new Dictionary>(); + _planeStorages = new Dictionary>(); _pictureWidth = pictureWidth; _pictureHeight = pictureHeight; } @@ -53,7 +54,7 @@ namespace ProjectStormtrooper /// Название набора public void AddSet(string name) { - _planeStorages.Add(name, new PlanesGenericCollection(_pictureWidth, _pictureHeight)); + _planeStorages.Add(new PlanesCollectionInfo(name, ""), new PlanesGenericCollection(_pictureWidth, _pictureHeight)); } /// /// Удаление набора @@ -61,8 +62,9 @@ namespace ProjectStormtrooper /// Название набора public void DelSet(string name) { - if (_planeStorages.ContainsKey(name)) - _planeStorages.Remove(name); + var info = new PlanesCollectionInfo(name, ""); + if (_planeStorages.ContainsKey(info)) + _planeStorages.Remove(info); } /// /// Доступ к набору @@ -73,8 +75,9 @@ namespace ProjectStormtrooper { get { - if (_planeStorages.ContainsKey(ind)) - return _planeStorages[ind]; + var info = new PlanesCollectionInfo(ind, ""); + if (_planeStorages.ContainsKey(info)) + return _planeStorages[info]; return null; } } @@ -104,7 +107,7 @@ namespace ProjectStormtrooper { throw new Exception("Невалиданя операция, нет данных для сохранения"); } - sw.WriteLine($"{storage.Key}{_separatorForKeyValue}{storageString}"); + sw.WriteLine($"{storage.Key.Name}{_separatorForKeyValue}{storageString}"); } } } @@ -152,7 +155,7 @@ namespace ProjectStormtrooper } } } - _planeStorages.Add(record[0], collection); + _planeStorages.Add(new PlanesCollectionInfo(record[0], ""), collection); currentLine = sr.ReadLine(); } }