From ac3e17579d08735ca54a62cda8296395853cbf31 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Sat, 16 Dec 2023 23:47:18 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20PlanesGenericStorage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlanesCollectionInfo.cs | 23 +++++++++++++++++++ .../PlanesGenericStorage.cs | 23 +++++++++++-------- 2 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 ProjectStormtrooper/ProjectStormtrooper/PlanesCollectionInfo.cs 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(); } }