From caf208b305067488c12ade42bcaab110b6fdc11e Mon Sep 17 00:00:00 2001 From: AparyanLuiza Date: Fri, 29 Dec 2023 06:20:55 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=BE=D0=B2.=20?= =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=20=D0=BB=D0=B0=D0=B1?= =?UTF-8?q?=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormBulldozerCollections.Designer.cs | 54 +++++++++++++----- ProjectBulldozer/FormBulldozerCollections.cs | 38 ++++++++++--- .../FormBulldozerCollections.resx | 3 + .../Generics/BulldozerGenericCollection.cs | 23 ++++++-- .../Generics/DrawingBulldozerEqutables.cs.cs | 55 +++++++++++++++++++ ProjectBulldozer/Generics/SetGeneric.cs | 23 ++++++-- .../Generics/TractorCompareByColor.cs | 38 +++++++++++++ .../Generics/TractorCompareByType.cs | 29 ++++++++++ .../Generics/TractorGenericStorage.cs | 28 ++++------ .../Generics/TractorsCollectionInfo.cs | 29 ++++++++++ 10 files changed, 272 insertions(+), 48 deletions(-) create mode 100644 ProjectBulldozer/Generics/DrawingBulldozerEqutables.cs.cs create mode 100644 ProjectBulldozer/Generics/TractorCompareByColor.cs create mode 100644 ProjectBulldozer/Generics/TractorCompareByType.cs create mode 100644 ProjectBulldozer/Generics/TractorsCollectionInfo.cs diff --git a/ProjectBulldozer/FormBulldozerCollections.Designer.cs b/ProjectBulldozer/FormBulldozerCollections.Designer.cs index 0b6c7d3..3ee407f 100644 --- a/ProjectBulldozer/FormBulldozerCollections.Designer.cs +++ b/ProjectBulldozer/FormBulldozerCollections.Designer.cs @@ -25,6 +25,8 @@ namespace ProjectBulldozer сохранитьToolStripMenuItem = new ToolStripMenuItem(); загрузитьToolStripMenuItem = new ToolStripMenuItem(); toolStripMenuItem1 = new ToolStripMenuItem(); + ButtonSortByType = new Button(); + ButtonSortByColor = new Button(); ((ISupportInitialize)pictureBoxCollections).BeginInit(); groupBox1.SuspendLayout(); Instruments.SuspendLayout(); @@ -34,17 +36,17 @@ namespace ProjectBulldozer // maskedTextBoxNumber // maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - maskedTextBoxNumber.Location = new Point(33, 356); + maskedTextBoxNumber.Location = new Point(35, 379); maskedTextBoxNumber.Margin = new Padding(3, 2, 3, 2); maskedTextBoxNumber.Mask = "00"; maskedTextBoxNumber.Name = "maskedTextBoxNumber"; - maskedTextBoxNumber.Size = new Size(131, 23); + maskedTextBoxNumber.Size = new Size(132, 23); maskedTextBoxNumber.TabIndex = 4; // // ButtonRefreshCollection // ButtonRefreshCollection.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - ButtonRefreshCollection.Location = new Point(33, 499); + ButtonRefreshCollection.Location = new Point(33, 441); ButtonRefreshCollection.Margin = new Padding(3, 2, 3, 2); ButtonRefreshCollection.Name = "ButtonRefreshCollection"; ButtonRefreshCollection.Size = new Size(131, 31); @@ -56,7 +58,7 @@ namespace ProjectBulldozer // ButtonRemoveTractor // ButtonRemoveTractor.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - ButtonRemoveTractor.Location = new Point(33, 393); + ButtonRemoveTractor.Location = new Point(35, 406); ButtonRemoveTractor.Margin = new Padding(3, 2, 3, 2); ButtonRemoveTractor.Name = "ButtonRemoveTractor"; ButtonRemoveTractor.Size = new Size(131, 31); @@ -68,7 +70,7 @@ namespace ProjectBulldozer // ButtonAddTractor // ButtonAddTractor.Anchor = AnchorStyles.Top; - ButtonAddTractor.Location = new Point(33, 323); + ButtonAddTractor.Location = new Point(35, 337); ButtonAddTractor.Margin = new Padding(3, 2, 3, 2); ButtonAddTractor.Name = "ButtonAddTractor"; ButtonAddTractor.Size = new Size(131, 29); @@ -83,14 +85,14 @@ namespace ProjectBulldozer pictureBoxCollections.Location = new Point(0, 26); pictureBoxCollections.Margin = new Padding(3, 2, 3, 2); pictureBoxCollections.Name = "pictureBoxCollections"; - pictureBoxCollections.Size = new Size(697, 404); + pictureBoxCollections.Size = new Size(697, 474); pictureBoxCollections.TabIndex = 1; pictureBoxCollections.TabStop = false; pictureBoxCollections.Click += pictureBoxCollections_Click; // // textBoxStorageName // - textBoxStorageName.Location = new Point(27, 32); + textBoxStorageName.Location = new Point(27, 22); textBoxStorageName.Name = "textBoxStorageName"; textBoxStorageName.Size = new Size(131, 23); textBoxStorageName.TabIndex = 5; @@ -103,7 +105,7 @@ namespace ProjectBulldozer groupBox1.Controls.Add(textBoxStorageName); groupBox1.Location = new Point(6, 22); groupBox1.Name = "groupBox1"; - groupBox1.Size = new Size(189, 296); + groupBox1.Size = new Size(189, 219); groupBox1.TabIndex = 5; groupBox1.TabStop = false; groupBox1.Text = "Наборы"; @@ -112,7 +114,7 @@ namespace ProjectBulldozer // listBoxStorage.FormattingEnabled = true; listBoxStorage.ItemHeight = 15; - listBoxStorage.Location = new Point(27, 122); + listBoxStorage.Location = new Point(27, 84); listBoxStorage.Name = "listBoxStorage"; listBoxStorage.Size = new Size(131, 94); listBoxStorage.TabIndex = 9; @@ -121,7 +123,7 @@ namespace ProjectBulldozer // ButtonAddObject // ButtonAddObject.Anchor = AnchorStyles.Top; - ButtonAddObject.Location = new Point(27, 72); + ButtonAddObject.Location = new Point(27, 50); ButtonAddObject.Margin = new Padding(3, 2, 3, 2); ButtonAddObject.Name = "ButtonAddObject"; ButtonAddObject.Size = new Size(131, 29); @@ -133,7 +135,7 @@ namespace ProjectBulldozer // ButtonRemoveObject // ButtonRemoveObject.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - ButtonRemoveObject.Location = new Point(27, 244); + ButtonRemoveObject.Location = new Point(27, 181); ButtonRemoveObject.Margin = new Padding(3, 2, 3, 2); ButtonRemoveObject.Name = "ButtonRemoveObject"; ButtonRemoveObject.Size = new Size(131, 33); @@ -144,14 +146,16 @@ namespace ProjectBulldozer // // Instruments // + Instruments.Controls.Add(ButtonSortByColor); + Instruments.Controls.Add(ButtonSortByType); Instruments.Controls.Add(ButtonRefreshCollection); Instruments.Controls.Add(groupBox1); Instruments.Controls.Add(maskedTextBoxNumber); Instruments.Controls.Add(ButtonAddTractor); Instruments.Controls.Add(ButtonRemoveTractor); - Instruments.Location = new Point(697, 4); + Instruments.Location = new Point(703, 26); Instruments.Name = "Instruments"; - Instruments.Size = new Size(200, 541); + Instruments.Size = new Size(201, 464); Instruments.TabIndex = 6; Instruments.TabStop = false; Instruments.Text = "Инструменты"; @@ -207,11 +211,31 @@ namespace ProjectBulldozer toolStripMenuItem1.Name = "toolStripMenuItem1"; toolStripMenuItem1.Size = new Size(32, 19); // + // ButtonSortByType + // + ButtonSortByType.Location = new Point(33, 247); + ButtonSortByType.Name = "ButtonSortByType"; + ButtonSortByType.Size = new Size(131, 41); + ButtonSortByType.TabIndex = 7; + ButtonSortByType.Text = "Сортировать по типу"; + ButtonSortByType.UseVisualStyleBackColor = true; + ButtonSortByType.Click += ButtonSortByType_Click; + // + // ButtonSortByColor + // + ButtonSortByColor.Location = new Point(33, 294); + ButtonSortByColor.Name = "ButtonSortByColor"; + ButtonSortByColor.Size = new Size(131, 38); + ButtonSortByColor.TabIndex = 8; + ButtonSortByColor.Text = "Сортировать по цвету"; + ButtonSortByColor.UseVisualStyleBackColor = true; + ButtonSortByColor.Click += ButtonSortByColor_Click; + // // FormTractorCollections // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(904, 439); + ClientSize = new Size(904, 509); Controls.Add(Instruments); Controls.Add(pictureBoxCollections); Controls.Add(menuStrip1); @@ -267,5 +291,7 @@ namespace ProjectBulldozer private ToolStripMenuItem сохранитьToolStripMenuItem; private ToolStripMenuItem загрузитьToolStripMenuItem; private ToolStripMenuItem toolStripMenuItem1; + private Button ButtonSortByColor; + private Button ButtonSortByType; } } \ No newline at end of file diff --git a/ProjectBulldozer/FormBulldozerCollections.cs b/ProjectBulldozer/FormBulldozerCollections.cs index 015a40a..20956dd 100644 --- a/ProjectBulldozer/FormBulldozerCollections.cs +++ b/ProjectBulldozer/FormBulldozerCollections.cs @@ -3,17 +3,14 @@ using ProjectBulldozer.Generics; using ProjectBulldozer.Drawning; using ProjectBulldozer.Exceptions; using Microsoft.Extensions.Logging; -using System.ComponentModel; -using System.Xml.Linq; namespace ProjectBulldozer { public partial class FormTractorCollections : Form { private readonly TractorGenericStorage _storage; - private readonly TractorGenericCollection _tractors; - readonly int countPlace = 10; - private readonly ILogger _logger; + private readonly ILogger _logger; + readonly int countPlace = 12; public FormTractorCollections() { InitializeComponent(); @@ -25,7 +22,6 @@ namespace ProjectBulldozer _storage = new TractorGenericStorage(pictureBoxCollections.Width, pictureBoxCollections.Height); _logger = logger; } - private void ReloadObjects() { int index = listBoxStorage.SelectedIndex; @@ -99,15 +95,19 @@ namespace ProjectBulldozer tractor._pictureHeight = pictureBoxCollections.Height; if (listBoxStorage.SelectedIndex == -1) return; + var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty]; string name = listBoxStorage.SelectedItem.ToString() ?? string.Empty; + if (obj == null) { return; } try { - if (obj + tractor) + + int addedIndex = obj + tractor; + if (addedIndex != -1 && addedIndex < countPlace) { MessageBox.Show("Объект добавлен"); pictureBoxCollections.Image = obj.ShowTractors(); @@ -124,6 +124,11 @@ namespace ProjectBulldozer MessageBox.Show(ex.Message); _logger.LogWarning($"{ex.Message}. Не удалось добавить объект"); } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + _logger.LogWarning($"{ex.Message}. Не удалось добавить объект"); + } } private void ButtonRemoveTractor_Click(object sender, EventArgs e) { @@ -160,7 +165,6 @@ namespace ProjectBulldozer _logger.LogWarning($"{ex.Message}. Не удалось удалить объект"); } } - private void ButtonRefreshCollection_Click(object sender, EventArgs e) { if (listBoxStorage.SelectedIndex == -1) return; @@ -206,6 +210,24 @@ namespace ProjectBulldozer } } } + private void ButtonSortByType_Click(object sender, EventArgs e) => CompareTractors(new TractorCompareByType()); + + private void ButtonSortByColor_Click(object sender, EventArgs e) => CompareTractors(new TractorCompareByColor()); + + private void CompareTractors(IComparer comparer) + { + if (listBoxStorage.SelectedIndex == -1) + { + return; + } + var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + return; + } + obj.Sort(comparer); + pictureBoxCollections.Image = obj.ShowTractors(); + } } } diff --git a/ProjectBulldozer/FormBulldozerCollections.resx b/ProjectBulldozer/FormBulldozerCollections.resx index 0a3f5bf..7ee3dd7 100644 --- a/ProjectBulldozer/FormBulldozerCollections.resx +++ b/ProjectBulldozer/FormBulldozerCollections.resx @@ -126,4 +126,7 @@ 286, 17 + + 25 + \ No newline at end of file diff --git a/ProjectBulldozer/Generics/BulldozerGenericCollection.cs b/ProjectBulldozer/Generics/BulldozerGenericCollection.cs index 65f3235..f04b53c 100644 --- a/ProjectBulldozer/Generics/BulldozerGenericCollection.cs +++ b/ProjectBulldozer/Generics/BulldozerGenericCollection.cs @@ -5,8 +5,10 @@ namespace ProjectBulldozer.Generics { internal class TractorGenericCollection where T : DrawingTractor where U : IMoveableObject { + //ширина/высота окна private readonly int _pictureWidth; private readonly int _pictureHeight; + //ширина/высота занимаемого места private readonly int _placeSizeWidth = 150; private readonly int _placeSizeHeight = 130; private readonly SetGeneric _collection; @@ -19,10 +21,11 @@ namespace ProjectBulldozer.Generics _pictureHeight = picHeight; _collection = new SetGeneric(width * height); } - public static bool operator +(TractorGenericCollection collect, T? tract) + public static int operator +(TractorGenericCollection collect, T? tractor) { - if (tract == null) return false; - return collect._collection.Insert(tract); + if (tractor == null) return -1; + + return collect?._collection.Insert(tractor, new DrawingBulldozerEqutables())??-1; } public static T? operator -(TractorGenericCollection collect, int pos) { @@ -33,6 +36,10 @@ namespace ProjectBulldozer.Generics } return obj; } + public U? GetU(int pos) + { + return (U?)_collection[pos]?.GetMoveableObject; + } public Bitmap ShowTractors() { Bitmap bmp = new(_pictureWidth, _pictureHeight); @@ -48,7 +55,7 @@ namespace ProjectBulldozer.Generics { for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j) { - //линия рамзетки места + //линия разметки места g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 3, j * _placeSizeHeight); } g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight); @@ -60,17 +67,21 @@ namespace ProjectBulldozer.Generics int height = _pictureHeight / _placeSizeHeight; for (int i = 0; i < _collection.Count; i++) { + // Получение объекта var obj = _collection[i]; + // Установка позиции obj?.SetPosition( (int)((width - 1) * _placeSizeWidth - (i % width * _placeSizeWidth)), (int)((height - 1) * _placeSizeHeight - (i / width * _placeSizeHeight)) ); + // Прорисовка объекта obj?.DrawTransport(g); } } + + public void Sort(IComparer comparer) => _collection.SortSet(comparer); } - } - +} diff --git a/ProjectBulldozer/Generics/DrawingBulldozerEqutables.cs.cs b/ProjectBulldozer/Generics/DrawingBulldozerEqutables.cs.cs new file mode 100644 index 0000000..b8f656e --- /dev/null +++ b/ProjectBulldozer/Generics/DrawingBulldozerEqutables.cs.cs @@ -0,0 +1,55 @@ +using System.Diagnostics.CodeAnalysis; +using ProjectBulldozer.Drawning; +using ProjectBulldozer.Entities; + +namespace ProjectBulldozer.Generics +{ + internal class DrawingBulldozerEqutables : IEqualityComparer + { + public bool Equals(DrawingTractor? x, DrawingTractor? y) + { + if (x == null || x.EntityTractor == null) + { + throw new ArgumentNullException(nameof(x)); + } + if (y == null || y.EntityTractor == null) + { + throw new ArgumentNullException(nameof(y)); + } + if (x.GetType().Name != y.GetType().Name) + { + return false; + } + if (x.EntityTractor.Speed != y.EntityTractor.Speed) + { + return false; + } + if (x.EntityTractor.Weight != y.EntityTractor.Weight) + { + return false; + } + if (x.EntityTractor.BodyColor != y.EntityTractor.BodyColor) + { + return false; + } + if (x is DrawingBulldozer && y is DrawingBulldozer) + { + if ((x.EntityTractor as EntityBulldozer).Otval != (y.EntityTractor as EntityBulldozer).Otval) + { + return false; + } + if ((x.EntityTractor as EntityBulldozer).ThirdWheel != (y.EntityTractor as EntityBulldozer).ThirdWheel) + { + return false; + } + } + return true; + + } + + public int GetHashCode([DisallowNull] DrawingTractor obj) + { + return obj.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/ProjectBulldozer/Generics/SetGeneric.cs b/ProjectBulldozer/Generics/SetGeneric.cs index e72614a..76a6069 100644 --- a/ProjectBulldozer/Generics/SetGeneric.cs +++ b/ProjectBulldozer/Generics/SetGeneric.cs @@ -13,11 +13,14 @@ namespace ProjectBulldozer.Generics _places = new List(count); } /// Добавление объекта в набор - public bool Insert(T tract) + public int Insert(T tractor, IEqualityComparer? equal = null) { - return Insert(tract, 0); + if (_places.Count == _maxCount) + throw new StorageOverflowException(_maxCount); + Insert(tractor, 0, equal); + return 0; } - public bool Insert(T tract, int position) + public bool Insert(T tractor, int position, IEqualityComparer? equal = null) { if (position < 0 || position >= _maxCount) { @@ -27,7 +30,17 @@ namespace ProjectBulldozer.Generics { throw new StorageOverflowException(_maxCount); } - _places.Insert(position, tract); + if (equal != null) + { + foreach (var i in _places) + { + if (equal.Equals(i, tractor)) + { + throw new ApplicationException($"Объект уже существует"); + } + } + } + _places.Insert(position, tractor); return true; } public bool Remove(int position) @@ -67,5 +80,7 @@ namespace ProjectBulldozer.Generics } } } + + public void SortSet(IComparer comparer) => _places.Sort(comparer); } } diff --git a/ProjectBulldozer/Generics/TractorCompareByColor.cs b/ProjectBulldozer/Generics/TractorCompareByColor.cs new file mode 100644 index 0000000..0223888 --- /dev/null +++ b/ProjectBulldozer/Generics/TractorCompareByColor.cs @@ -0,0 +1,38 @@ +using ProjectBulldozer.Drawning; +using ProjectBulldozer.Entities; + +namespace ProjectBulldozer.Generics +{ + internal class TractorCompareByColor : IComparer + { + public int Compare(DrawingTractor? x, DrawingTractor? y) + { + if (x == null || x.EntityTractor == null) + { + throw new ArgumentNullException(nameof(x)); + } + if (y == null || y.EntityTractor == null) + { + throw new ArgumentNullException(nameof(y)); + } + if (x.EntityTractor.BodyColor != y.EntityTractor.BodyColor) + { + return x.EntityTractor.BodyColor.Name.CompareTo(y.EntityTractor.BodyColor.Name); + } + if (x.EntityTractor is EntityBulldozer _BulldozerX && y.EntityTractor is EntityBulldozer _BulldozertY) + { + var ElementsColorCompare = _BulldozerX.AdditionalColor.Name.CompareTo(_BulldozertY.AdditionalColor.Name); + if (ElementsColorCompare != 0) + { + return ElementsColorCompare; + } + } + var speedCompare = x.EntityTractor.Speed.CompareTo(y.EntityTractor.Speed); + if (speedCompare != 0) + { + return speedCompare; + } + return x.EntityTractor.Weight.CompareTo(y.EntityTractor.Weight); + } + } +} diff --git a/ProjectBulldozer/Generics/TractorCompareByType.cs b/ProjectBulldozer/Generics/TractorCompareByType.cs new file mode 100644 index 0000000..c2502e8 --- /dev/null +++ b/ProjectBulldozer/Generics/TractorCompareByType.cs @@ -0,0 +1,29 @@ +using ProjectBulldozer.Drawning; + +namespace ProjectBulldozer.Generics +{ + internal class TractorCompareByType : IComparer + { + public int Compare(DrawingTractor? x, DrawingTractor? y) + { + if (x == null || x.EntityTractor == null) + { + throw new ArgumentNullException(nameof(x)); + } + if (y == null || y.EntityTractor == null) + { + throw new ArgumentNullException(nameof(y)); + } + if (x.GetType().Name != y.GetType().Name) + { + return x.GetType().Name.CompareTo(y.GetType().Name); + } + var speedCompare = x.EntityTractor.Speed.CompareTo(y.EntityTractor.Speed); + if (speedCompare != 0) + { + return speedCompare; + } + return x.EntityTractor.Weight.CompareTo(y.EntityTractor.Weight); + } + } +} diff --git a/ProjectBulldozer/Generics/TractorGenericStorage.cs b/ProjectBulldozer/Generics/TractorGenericStorage.cs index 07a2f5d..c973119 100644 --- a/ProjectBulldozer/Generics/TractorGenericStorage.cs +++ b/ProjectBulldozer/Generics/TractorGenericStorage.cs @@ -9,38 +9,36 @@ namespace ProjectBulldozer.Generics private static readonly char _separatorForKeyValue = '|'; private readonly char _separatorRecords = ';'; private static readonly char _separatorForObject = ':'; - readonly Dictionary> _TractorsStorage; - public List Keys => _TractorsStorage.Keys.ToList(); + readonly Dictionary> _TractorsStorage; + public List Keys => _TractorsStorage.Keys.ToList(); private readonly int _pictureWidth; private readonly int _pictureHeight; public TractorGenericStorage(int pictureWidth, int pictureHeight) { - _TractorsStorage = new Dictionary>(); + _TractorsStorage = new Dictionary>(); _pictureWidth = pictureWidth; _pictureHeight = pictureHeight; } public void AddSet(string name) { - if (!_TractorsStorage.ContainsKey(name)) + if (!_TractorsStorage.ContainsKey(new TractorsCollectionInfo(name, ""))) { - _TractorsStorage.Add(name, new TractorGenericCollection(_pictureWidth, _pictureHeight)); + _TractorsStorage.Add(new TractorsCollectionInfo(name, ""), new TractorGenericCollection(_pictureWidth, _pictureHeight)); } } public void DelSet(string name) { - if (_TractorsStorage.ContainsKey(name)) + if (_TractorsStorage.ContainsKey(new TractorsCollectionInfo(name, ""))) { - _TractorsStorage.Remove(name); + _TractorsStorage.Remove(new TractorsCollectionInfo(name, "")); } } public TractorGenericCollection? this[string ind] { get { - if (_TractorsStorage.ContainsKey(ind)) - { - return _TractorsStorage[ind]; - } + var info = new TractorsCollectionInfo(ind, ""); + if (_TractorsStorage.ContainsKey(info)) return _TractorsStorage[info]; return null; } } @@ -51,9 +49,7 @@ namespace ProjectBulldozer.Generics File.Delete(filename); } StringBuilder data = new(); - - foreach (KeyValuePair> - record in _TractorsStorage) + foreach (KeyValuePair> record in _TractorsStorage) { StringBuilder records = new(); foreach (DrawingTractor? elem in record.Value.GetTractors) @@ -112,13 +108,13 @@ namespace ProjectBulldozer.Generics _pictureWidth, _pictureHeight); if (tractor != null) { - if ((collection + tractor)) + if ((collection + tractor)==-1) { throw new ApplicationException("Ошибка добавления в коллекцию"); } } } - _TractorsStorage.Add(record[0], collection); + _TractorsStorage.Add(new TractorsCollectionInfo(record[0], string.Empty), collection); } return true; } diff --git a/ProjectBulldozer/Generics/TractorsCollectionInfo.cs b/ProjectBulldozer/Generics/TractorsCollectionInfo.cs new file mode 100644 index 0000000..32aaa15 --- /dev/null +++ b/ProjectBulldozer/Generics/TractorsCollectionInfo.cs @@ -0,0 +1,29 @@ +namespace ProjectBulldozer.Generics +{ + internal class TractorsCollectionInfo : IEquatable + { + public string Name { get; private set; } + + public string Description { get; private set; } + + public TractorsCollectionInfo(string name, string description) + { + Name = name; + Description = description; + } + + public bool Equals(TractorsCollectionInfo? other) + { + return Name == other.Name; + } + + public override int GetHashCode() + { + return Name.GetHashCode(); + } + public override string ToString() + { + return Name; + } + } +}