Compare commits
No commits in common. "cc3bc5bf34d44f102126ac4f6c4f0e6ffe1294e0" and "d95866ee896b210a91be28c3fe0433bf4150a64f" have entirely different histories.
cc3bc5bf34
...
d95866ee89
66
Airbus/FormAirbusCollection.Designer.cs
generated
66
Airbus/FormAirbusCollection.Designer.cs
generated
@ -46,8 +46,6 @@
|
||||
LoadToolStripMenuItem = new ToolStripMenuItem();
|
||||
openFileDialog = new OpenFileDialog();
|
||||
saveFileDialog = new SaveFileDialog();
|
||||
buttonSortByType = new Button();
|
||||
buttonSortByColor = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
@ -55,10 +53,10 @@
|
||||
// buttonAddAirbus
|
||||
//
|
||||
buttonAddAirbus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonAddAirbus.Location = new Point(638, 458);
|
||||
buttonAddAirbus.Location = new Point(654, 443);
|
||||
buttonAddAirbus.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonAddAirbus.Name = "buttonAddAirbus";
|
||||
buttonAddAirbus.Size = new Size(173, 37);
|
||||
buttonAddAirbus.Size = new Size(157, 37);
|
||||
buttonAddAirbus.TabIndex = 0;
|
||||
buttonAddAirbus.Text = "Добавить самолёт";
|
||||
buttonAddAirbus.UseVisualStyleBackColor = true;
|
||||
@ -69,7 +67,7 @@
|
||||
pictureBoxCollection.Location = new Point(0, 28);
|
||||
pictureBoxCollection.Margin = new Padding(3, 4, 3, 4);
|
||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
pictureBoxCollection.Size = new Size(620, 545);
|
||||
pictureBoxCollection.Size = new Size(630, 556);
|
||||
pictureBoxCollection.TabIndex = 1;
|
||||
pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
@ -78,7 +76,7 @@
|
||||
labelInstruments.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelInstruments.AutoSize = true;
|
||||
labelInstruments.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
labelInstruments.Location = new Point(638, 28);
|
||||
labelInstruments.Location = new Point(654, 23);
|
||||
labelInstruments.Name = "labelInstruments";
|
||||
labelInstruments.Size = new Size(136, 28);
|
||||
labelInstruments.TabIndex = 2;
|
||||
@ -87,10 +85,10 @@
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonUpdate.Location = new Point(638, 160);
|
||||
buttonUpdate.Location = new Point(654, 173);
|
||||
buttonUpdate.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(166, 33);
|
||||
buttonUpdate.Size = new Size(150, 33);
|
||||
buttonUpdate.TabIndex = 3;
|
||||
buttonUpdate.Text = "Обновить набор";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
@ -99,10 +97,10 @@
|
||||
// buttonDeleteAirbus
|
||||
//
|
||||
buttonDeleteAirbus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonDeleteAirbus.Location = new Point(638, 537);
|
||||
buttonDeleteAirbus.Location = new Point(654, 523);
|
||||
buttonDeleteAirbus.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonDeleteAirbus.Name = "buttonDeleteAirbus";
|
||||
buttonDeleteAirbus.Size = new Size(173, 37);
|
||||
buttonDeleteAirbus.Size = new Size(157, 37);
|
||||
buttonDeleteAirbus.TabIndex = 4;
|
||||
buttonDeleteAirbus.Text = "Удалить самолёт";
|
||||
buttonDeleteAirbus.UseVisualStyleBackColor = true;
|
||||
@ -111,11 +109,11 @@
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
maskedTextBoxNumber.Location = new Point(638, 502);
|
||||
maskedTextBoxNumber.Location = new Point(654, 487);
|
||||
maskedTextBoxNumber.Margin = new Padding(3, 4, 3, 4);
|
||||
maskedTextBoxNumber.Mask = "00";
|
||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
maskedTextBoxNumber.Size = new Size(173, 27);
|
||||
maskedTextBoxNumber.Size = new Size(157, 27);
|
||||
maskedTextBoxNumber.TabIndex = 5;
|
||||
maskedTextBoxNumber.ValidatingType = typeof(int);
|
||||
//
|
||||
@ -123,7 +121,7 @@
|
||||
//
|
||||
label1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(638, 65);
|
||||
label1.Location = new Point(654, 62);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(66, 20);
|
||||
label1.TabIndex = 7;
|
||||
@ -133,17 +131,17 @@
|
||||
//
|
||||
listBoxStorages.FormattingEnabled = true;
|
||||
listBoxStorages.ItemHeight = 20;
|
||||
listBoxStorages.Location = new Point(638, 196);
|
||||
listBoxStorages.Location = new Point(654, 213);
|
||||
listBoxStorages.Name = "listBoxStorages";
|
||||
listBoxStorages.Size = new Size(166, 124);
|
||||
listBoxStorages.Size = new Size(150, 144);
|
||||
listBoxStorages.TabIndex = 8;
|
||||
listBoxStorages.SelectedIndexChanged += listBoxObjects_SelectedIndexChanged;
|
||||
//
|
||||
// buttonAddStorage
|
||||
//
|
||||
buttonAddStorage.Location = new Point(638, 124);
|
||||
buttonAddStorage.Location = new Point(654, 136);
|
||||
buttonAddStorage.Name = "buttonAddStorage";
|
||||
buttonAddStorage.Size = new Size(166, 33);
|
||||
buttonAddStorage.Size = new Size(150, 33);
|
||||
buttonAddStorage.TabIndex = 9;
|
||||
buttonAddStorage.Text = "Добавить набор";
|
||||
buttonAddStorage.UseVisualStyleBackColor = true;
|
||||
@ -151,9 +149,9 @@
|
||||
//
|
||||
// buttonDeleteStorage
|
||||
//
|
||||
buttonDeleteStorage.Location = new Point(638, 324);
|
||||
buttonDeleteStorage.Location = new Point(654, 364);
|
||||
buttonDeleteStorage.Name = "buttonDeleteStorage";
|
||||
buttonDeleteStorage.Size = new Size(166, 33);
|
||||
buttonDeleteStorage.Size = new Size(150, 33);
|
||||
buttonDeleteStorage.TabIndex = 10;
|
||||
buttonDeleteStorage.Text = "Удалить набор";
|
||||
buttonDeleteStorage.UseVisualStyleBackColor = true;
|
||||
@ -161,9 +159,9 @@
|
||||
//
|
||||
// textBoxStorageName
|
||||
//
|
||||
textBoxStorageName.Location = new Point(638, 93);
|
||||
textBoxStorageName.Location = new Point(654, 103);
|
||||
textBoxStorageName.Name = "textBoxStorageName";
|
||||
textBoxStorageName.Size = new Size(166, 27);
|
||||
textBoxStorageName.Size = new Size(150, 27);
|
||||
textBoxStorageName.TabIndex = 11;
|
||||
//
|
||||
// menuStrip
|
||||
@ -206,33 +204,11 @@
|
||||
saveFileDialog.Filter = "txt file | *.txt";
|
||||
saveFileDialog.OverwritePrompt = false;
|
||||
//
|
||||
// buttonSortByType
|
||||
//
|
||||
buttonSortByType.Location = new Point(638, 372);
|
||||
buttonSortByType.Name = "buttonSortByType";
|
||||
buttonSortByType.Size = new Size(166, 33);
|
||||
buttonSortByType.TabIndex = 13;
|
||||
buttonSortByType.Text = "Сортировка по типу";
|
||||
buttonSortByType.UseVisualStyleBackColor = true;
|
||||
buttonSortByType.Click += buttonSortByType_Click;
|
||||
//
|
||||
// buttonSortByColor
|
||||
//
|
||||
buttonSortByColor.Location = new Point(638, 408);
|
||||
buttonSortByColor.Name = "buttonSortByColor";
|
||||
buttonSortByColor.Size = new Size(166, 31);
|
||||
buttonSortByColor.TabIndex = 14;
|
||||
buttonSortByColor.Text = "Сортировка по цвету";
|
||||
buttonSortByColor.UseVisualStyleBackColor = true;
|
||||
buttonSortByColor.Click += buttonSortByColor_Click;
|
||||
//
|
||||
// FormAirbusCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(827, 585);
|
||||
Controls.Add(buttonSortByColor);
|
||||
Controls.Add(buttonSortByType);
|
||||
ClientSize = new Size(827, 591);
|
||||
Controls.Add(textBoxStorageName);
|
||||
Controls.Add(buttonDeleteStorage);
|
||||
Controls.Add(buttonAddStorage);
|
||||
@ -276,7 +252,5 @@
|
||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private Button buttonSortByType;
|
||||
private Button buttonSortByColor;
|
||||
}
|
||||
}
|
@ -29,29 +29,9 @@ namespace ProjectAirbus
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
private void buttonSortByType_Click(object sender, EventArgs e) => CompareAirbus(new AirbusCompareByType());
|
||||
|
||||
private void buttonSortByColor_Click(object sender, EventArgs e) => CompareAirbus(new AirbusCompareByColor());
|
||||
|
||||
// Сортировка по сравнителю
|
||||
private void CompareAirbus(IComparer<DrawningAirbus?> comparer)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
obj.Sort(comparer);
|
||||
pictureBoxCollection.Image = obj.ShowAirbus();
|
||||
}
|
||||
|
||||
// Обработка нажатия "Сохранение"
|
||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
@ -95,7 +75,7 @@ namespace ProjectAirbus
|
||||
listBoxStorages.Items.Clear();
|
||||
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||
{
|
||||
listBoxStorages.Items.Add(_storage.Keys[i].Name);
|
||||
listBoxStorages.Items.Add(_storage.Keys[i]);
|
||||
}
|
||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
|
||||
{
|
||||
@ -183,11 +163,6 @@ namespace ProjectAirbus
|
||||
MessageBox.Show(ex.Message);
|
||||
_logger.LogWarning(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
_logger.LogWarning(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
// удалить самолёт
|
||||
|
@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirbus.Generics
|
||||
{
|
||||
internal class AirbusCollectionInfo : IEquatable<AirbusCollectionInfo>
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public string Description { get; private set; }
|
||||
public AirbusCollectionInfo(string name, string description)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
}
|
||||
public bool Equals(AirbusCollectionInfo? other)
|
||||
{
|
||||
if (ReferenceEquals(other, null))
|
||||
return false;
|
||||
|
||||
return Name.Equals(other.Name);
|
||||
}
|
||||
public override int GetHashCode() => Name.GetHashCode();
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectAirbus.Drawnings;
|
||||
using ProjectAirbus.Entities;
|
||||
|
||||
namespace ProjectAirbus.Generics
|
||||
{
|
||||
internal class AirbusCompareByColor : IComparer<DrawningAirbus>
|
||||
{
|
||||
public int Compare(DrawningAirbus? x, DrawningAirbus? y)
|
||||
{
|
||||
if (x == null || x.EntityAirbus == null)
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
|
||||
if (y == null || y.EntityAirbus == null)
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
|
||||
var xPlane = x.EntityAirbus;
|
||||
var yPlane = y.EntityAirbus;
|
||||
|
||||
if (xPlane.BodyColor != yPlane.BodyColor)
|
||||
return xPlane.BodyColor.Name.CompareTo(yPlane.BodyColor.Name);
|
||||
|
||||
var speedCompare = x.EntityAirbus.Speed.CompareTo(y.EntityAirbus.Speed);
|
||||
if (speedCompare != 0)
|
||||
return speedCompare;
|
||||
|
||||
return x.EntityAirbus.Weight.CompareTo(y.EntityAirbus.Weight);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectAirbus.Drawnings;
|
||||
|
||||
namespace ProjectAirbus.Generics
|
||||
{
|
||||
internal class AirbusCompareByType : IComparer<DrawningAirbus>
|
||||
{
|
||||
public int Compare(DrawningAirbus? x, DrawningAirbus? y)
|
||||
{
|
||||
if (x == null || x.EntityAirbus == null)
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
|
||||
if (y == null || y.EntityAirbus == null)
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
|
||||
if (x.GetType().Name != y.GetType().Name)
|
||||
return x.GetType().Name.CompareTo(y.GetType().Name);
|
||||
|
||||
var speedCompare = x.EntityAirbus.Speed.CompareTo(y.EntityAirbus.Speed);
|
||||
if (speedCompare != 0)
|
||||
return speedCompare;
|
||||
|
||||
return x.EntityAirbus.Weight.CompareTo(y.EntityAirbus.Weight);
|
||||
}
|
||||
}
|
||||
}
|
@ -16,8 +16,8 @@ namespace ProjectAirbus.Generics
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
// Размер занимаемого места 89х34
|
||||
private readonly int _placeSizeWidth = 89;
|
||||
private readonly int _placeSizeHeight = 34;
|
||||
private readonly int _placeSizeWidth = 189;
|
||||
private readonly int _placeSizeHeight = 134;
|
||||
// коллекция
|
||||
private readonly SetGeneric<T> _collection;
|
||||
|
||||
@ -31,14 +31,11 @@ namespace ProjectAirbus.Generics
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
|
||||
// Сортировка
|
||||
public void Sort(IComparer<T?> comparer) => _collection.SortSet(comparer);
|
||||
|
||||
public static int operator +(AirbusGenericCollection<T, U> collect, T? obj)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
return collect._collection.Insert(obj, new DrawningAirbusEqutables());
|
||||
return collect._collection.Insert(obj);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -13,9 +13,9 @@ namespace ProjectAirbus.Generics
|
||||
internal class AirbusGenericStorage
|
||||
{
|
||||
//Словарь (хранилище)
|
||||
readonly Dictionary<AirbusCollectionInfo, AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>> _airbusStorages;
|
||||
readonly Dictionary<string, AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>> _airbusStorages;
|
||||
//Возвращение списка названий наборов
|
||||
public List<AirbusCollectionInfo> Keys => _airbusStorages.Keys.ToList();
|
||||
public List<string> Keys => _airbusStorages.Keys.ToList();
|
||||
//Ширина окна отрисовки
|
||||
private readonly int _pictureWidth;
|
||||
//Высота окна отрисовки
|
||||
@ -28,9 +28,10 @@ namespace ProjectAirbus.Generics
|
||||
// Разделитель для записи информации по объекту в файл
|
||||
private static readonly char _separatorForObject = ':';
|
||||
|
||||
|
||||
public AirbusGenericStorage(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_airbusStorages = new Dictionary<AirbusCollectionInfo, AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>>();
|
||||
_airbusStorages = new Dictionary<string, AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
@ -38,24 +39,25 @@ namespace ProjectAirbus.Generics
|
||||
// Добавление набора
|
||||
public void AddSet(string name)
|
||||
{
|
||||
AirbusCollectionInfo set = new AirbusCollectionInfo(name, string.Empty);
|
||||
|
||||
if (_airbusStorages.ContainsKey(set))
|
||||
return;
|
||||
|
||||
_airbusStorages.Add(set, new AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>(_pictureWidth, _pictureHeight));
|
||||
// проверка, что нет набора с таким именем
|
||||
foreach (string nameStorage in Keys)
|
||||
{
|
||||
if (nameStorage == name)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
_airbusStorages.Add(name, new AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>(_pictureWidth, _pictureHeight));
|
||||
}
|
||||
|
||||
// Удаление набора
|
||||
public void DelSet(string name)
|
||||
{
|
||||
AirbusCollectionInfo set = new AirbusCollectionInfo(name, string.Empty);
|
||||
if ( _airbusStorages.ContainsKey(name))
|
||||
{
|
||||
_airbusStorages.Remove(name);
|
||||
}
|
||||
|
||||
// проверка, что нет набора с таким именем
|
||||
if (!_airbusStorages.ContainsKey(set))
|
||||
return;
|
||||
|
||||
_airbusStorages.Remove(set);
|
||||
}
|
||||
|
||||
// Доступ к набору
|
||||
@ -63,13 +65,11 @@ namespace ProjectAirbus.Generics
|
||||
{
|
||||
get
|
||||
{
|
||||
AirbusCollectionInfo set = new AirbusCollectionInfo(ind, string.Empty);
|
||||
|
||||
if (!_airbusStorages.ContainsKey(set))
|
||||
if (_airbusStorages.ContainsKey(ind))
|
||||
{
|
||||
return null;
|
||||
return _airbusStorages[ind];
|
||||
}
|
||||
return _airbusStorages[set];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ namespace ProjectAirbus.Generics
|
||||
}
|
||||
}
|
||||
}
|
||||
_airbusStorages.Add(new AirbusCollectionInfo(record[0], string.Empty), collection);
|
||||
_airbusStorages.Add(record[0], collection);
|
||||
curLine = sr.ReadLine();
|
||||
}
|
||||
}
|
||||
|
@ -1,57 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ProjectAirbus.Drawnings;
|
||||
using ProjectAirbus.Entities;
|
||||
|
||||
namespace ProjectAirbus.Generics
|
||||
{
|
||||
internal class DrawningAirbusEqutables : IEqualityComparer<DrawningAirbus?>
|
||||
{
|
||||
public bool Equals(DrawningAirbus? x, DrawningAirbus? y)
|
||||
{
|
||||
if (x == null && x.EntityAirbus == null)
|
||||
throw new ArgumentNullException(nameof(x));
|
||||
|
||||
if (y == null && y.EntityAirbus == null)
|
||||
throw new ArgumentNullException(nameof(y));
|
||||
|
||||
if ((x.GetType().Name != y.GetType().Name))
|
||||
return false;
|
||||
|
||||
if (x.EntityAirbus.Speed != y.EntityAirbus.Speed)
|
||||
return false;
|
||||
|
||||
if (x.EntityAirbus.Weight != y.EntityAirbus.Weight)
|
||||
return false;
|
||||
|
||||
if (x.EntityAirbus.BodyColor != y.EntityAirbus.BodyColor)
|
||||
return false;
|
||||
|
||||
if (x is DrawningPlane && y is DrawningPlane)
|
||||
{
|
||||
var xPlane = (EntityPlane)x.EntityAirbus;
|
||||
var yPlane = (EntityPlane)y.EntityAirbus;
|
||||
|
||||
if (xPlane.AdditionalColor != yPlane.AdditionalColor)
|
||||
return false;
|
||||
|
||||
if (xPlane.IsAdditionalEngine != yPlane.IsAdditionalEngine)
|
||||
return false;
|
||||
|
||||
if (xPlane.IsCompartment != yPlane.IsCompartment)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int GetHashCode([DisallowNull] DrawningAirbus? obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -23,17 +23,14 @@ namespace ProjectAirbus.Generics
|
||||
_places = new List<T?>(count);
|
||||
}
|
||||
|
||||
// сортировка набора
|
||||
public void SortSet(IComparer<T?> comparer) => _places.Sort(comparer);
|
||||
|
||||
// Добавление объекта в начало набора
|
||||
public int Insert(T airbus, IEqualityComparer<T?>? equal = null)
|
||||
// Добавление объекта в начало набора
|
||||
public int Insert(T airbus)
|
||||
{
|
||||
return Insert(airbus, 0, equal);
|
||||
return Insert(airbus, 0);
|
||||
}
|
||||
|
||||
// Добавление объекта в набор на конкретную позицию
|
||||
public int Insert(T airbus, int position, IEqualityComparer<T?>? equal = null)
|
||||
public int Insert(T airbus, int position)
|
||||
{
|
||||
if (Count >= _maxCount)
|
||||
{
|
||||
@ -43,11 +40,6 @@ namespace ProjectAirbus.Generics
|
||||
{
|
||||
throw new IndexOutOfRangeException("Индекс вне границ коллекции");
|
||||
}
|
||||
if (equal != null && _places.Contains(airbus,equal))
|
||||
{
|
||||
throw new ArgumentException("Данный объект уже есть в коллекции");
|
||||
}
|
||||
|
||||
_places.Insert(position, airbus);
|
||||
return 0;
|
||||
}
|
||||
@ -63,27 +55,27 @@ namespace ProjectAirbus.Generics
|
||||
return true;
|
||||
}
|
||||
|
||||
// Получение объекта из набора по позиции
|
||||
public T? this[int position]
|
||||
{
|
||||
get
|
||||
// Получение объекта из набора по позиции
|
||||
public T? this[int position]
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
get
|
||||
{
|
||||
return null;
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _places[position];
|
||||
}
|
||||
return _places[position];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (position < 0 || Count >= _maxCount)
|
||||
set
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (position < 0 || Count >= _maxCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_places.Insert(position, value);
|
||||
_places.Insert(position, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Проход по списку
|
||||
public IEnumerable<T?> GetAirbus(int? maxAirbus = null)
|
||||
@ -97,5 +89,6 @@ namespace ProjectAirbus.Generics
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="nlog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="serilog.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
11
Airbus/nlog.config
Normal file
11
Airbus/nlog.config
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true" internalLogLevel="Info">
|
||||
<targets>
|
||||
<target xsi:type="File" name="tofile" fileName="carlog-${shortdate}.log" />
|
||||
</targets>
|
||||
<rules>
|
||||
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
||||
</rules>
|
||||
</nlog>
|
||||
</configuration>
|
Loading…
Reference in New Issue
Block a user