Compare commits

...

2 Commits

11 changed files with 277 additions and 82 deletions

View File

@ -46,6 +46,8 @@
LoadToolStripMenuItem = new ToolStripMenuItem(); LoadToolStripMenuItem = new ToolStripMenuItem();
openFileDialog = new OpenFileDialog(); openFileDialog = new OpenFileDialog();
saveFileDialog = new SaveFileDialog(); saveFileDialog = new SaveFileDialog();
buttonSortByType = new Button();
buttonSortByColor = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
menuStrip.SuspendLayout(); menuStrip.SuspendLayout();
SuspendLayout(); SuspendLayout();
@ -53,10 +55,10 @@
// buttonAddAirbus // buttonAddAirbus
// //
buttonAddAirbus.Anchor = AnchorStyles.Top | AnchorStyles.Right; buttonAddAirbus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonAddAirbus.Location = new Point(654, 443); buttonAddAirbus.Location = new Point(638, 458);
buttonAddAirbus.Margin = new Padding(3, 4, 3, 4); buttonAddAirbus.Margin = new Padding(3, 4, 3, 4);
buttonAddAirbus.Name = "buttonAddAirbus"; buttonAddAirbus.Name = "buttonAddAirbus";
buttonAddAirbus.Size = new Size(157, 37); buttonAddAirbus.Size = new Size(173, 37);
buttonAddAirbus.TabIndex = 0; buttonAddAirbus.TabIndex = 0;
buttonAddAirbus.Text = "Добавить самолёт"; buttonAddAirbus.Text = "Добавить самолёт";
buttonAddAirbus.UseVisualStyleBackColor = true; buttonAddAirbus.UseVisualStyleBackColor = true;
@ -67,7 +69,7 @@
pictureBoxCollection.Location = new Point(0, 28); pictureBoxCollection.Location = new Point(0, 28);
pictureBoxCollection.Margin = new Padding(3, 4, 3, 4); pictureBoxCollection.Margin = new Padding(3, 4, 3, 4);
pictureBoxCollection.Name = "pictureBoxCollection"; pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(630, 556); pictureBoxCollection.Size = new Size(620, 545);
pictureBoxCollection.TabIndex = 1; pictureBoxCollection.TabIndex = 1;
pictureBoxCollection.TabStop = false; pictureBoxCollection.TabStop = false;
// //
@ -76,7 +78,7 @@
labelInstruments.Anchor = AnchorStyles.Top | AnchorStyles.Right; labelInstruments.Anchor = AnchorStyles.Top | AnchorStyles.Right;
labelInstruments.AutoSize = true; labelInstruments.AutoSize = true;
labelInstruments.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); labelInstruments.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
labelInstruments.Location = new Point(654, 23); labelInstruments.Location = new Point(638, 28);
labelInstruments.Name = "labelInstruments"; labelInstruments.Name = "labelInstruments";
labelInstruments.Size = new Size(136, 28); labelInstruments.Size = new Size(136, 28);
labelInstruments.TabIndex = 2; labelInstruments.TabIndex = 2;
@ -85,10 +87,10 @@
// buttonUpdate // buttonUpdate
// //
buttonUpdate.Anchor = AnchorStyles.Top | AnchorStyles.Right; buttonUpdate.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonUpdate.Location = new Point(654, 173); buttonUpdate.Location = new Point(638, 160);
buttonUpdate.Margin = new Padding(3, 4, 3, 4); buttonUpdate.Margin = new Padding(3, 4, 3, 4);
buttonUpdate.Name = "buttonUpdate"; buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(150, 33); buttonUpdate.Size = new Size(166, 33);
buttonUpdate.TabIndex = 3; buttonUpdate.TabIndex = 3;
buttonUpdate.Text = "Обновить набор"; buttonUpdate.Text = "Обновить набор";
buttonUpdate.UseVisualStyleBackColor = true; buttonUpdate.UseVisualStyleBackColor = true;
@ -97,10 +99,10 @@
// buttonDeleteAirbus // buttonDeleteAirbus
// //
buttonDeleteAirbus.Anchor = AnchorStyles.Top | AnchorStyles.Right; buttonDeleteAirbus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonDeleteAirbus.Location = new Point(654, 523); buttonDeleteAirbus.Location = new Point(638, 537);
buttonDeleteAirbus.Margin = new Padding(3, 4, 3, 4); buttonDeleteAirbus.Margin = new Padding(3, 4, 3, 4);
buttonDeleteAirbus.Name = "buttonDeleteAirbus"; buttonDeleteAirbus.Name = "buttonDeleteAirbus";
buttonDeleteAirbus.Size = new Size(157, 37); buttonDeleteAirbus.Size = new Size(173, 37);
buttonDeleteAirbus.TabIndex = 4; buttonDeleteAirbus.TabIndex = 4;
buttonDeleteAirbus.Text = "Удалить самолёт"; buttonDeleteAirbus.Text = "Удалить самолёт";
buttonDeleteAirbus.UseVisualStyleBackColor = true; buttonDeleteAirbus.UseVisualStyleBackColor = true;
@ -109,11 +111,11 @@
// maskedTextBoxNumber // maskedTextBoxNumber
// //
maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Right; maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Right;
maskedTextBoxNumber.Location = new Point(654, 487); maskedTextBoxNumber.Location = new Point(638, 502);
maskedTextBoxNumber.Margin = new Padding(3, 4, 3, 4); maskedTextBoxNumber.Margin = new Padding(3, 4, 3, 4);
maskedTextBoxNumber.Mask = "00"; maskedTextBoxNumber.Mask = "00";
maskedTextBoxNumber.Name = "maskedTextBoxNumber"; maskedTextBoxNumber.Name = "maskedTextBoxNumber";
maskedTextBoxNumber.Size = new Size(157, 27); maskedTextBoxNumber.Size = new Size(173, 27);
maskedTextBoxNumber.TabIndex = 5; maskedTextBoxNumber.TabIndex = 5;
maskedTextBoxNumber.ValidatingType = typeof(int); maskedTextBoxNumber.ValidatingType = typeof(int);
// //
@ -121,7 +123,7 @@
// //
label1.Anchor = AnchorStyles.Top | AnchorStyles.Right; label1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
label1.AutoSize = true; label1.AutoSize = true;
label1.Location = new Point(654, 62); label1.Location = new Point(638, 65);
label1.Name = "label1"; label1.Name = "label1";
label1.Size = new Size(66, 20); label1.Size = new Size(66, 20);
label1.TabIndex = 7; label1.TabIndex = 7;
@ -131,17 +133,17 @@
// //
listBoxStorages.FormattingEnabled = true; listBoxStorages.FormattingEnabled = true;
listBoxStorages.ItemHeight = 20; listBoxStorages.ItemHeight = 20;
listBoxStorages.Location = new Point(654, 213); listBoxStorages.Location = new Point(638, 196);
listBoxStorages.Name = "listBoxStorages"; listBoxStorages.Name = "listBoxStorages";
listBoxStorages.Size = new Size(150, 144); listBoxStorages.Size = new Size(166, 124);
listBoxStorages.TabIndex = 8; listBoxStorages.TabIndex = 8;
listBoxStorages.SelectedIndexChanged += listBoxObjects_SelectedIndexChanged; listBoxStorages.SelectedIndexChanged += listBoxObjects_SelectedIndexChanged;
// //
// buttonAddStorage // buttonAddStorage
// //
buttonAddStorage.Location = new Point(654, 136); buttonAddStorage.Location = new Point(638, 124);
buttonAddStorage.Name = "buttonAddStorage"; buttonAddStorage.Name = "buttonAddStorage";
buttonAddStorage.Size = new Size(150, 33); buttonAddStorage.Size = new Size(166, 33);
buttonAddStorage.TabIndex = 9; buttonAddStorage.TabIndex = 9;
buttonAddStorage.Text = "Добавить набор"; buttonAddStorage.Text = "Добавить набор";
buttonAddStorage.UseVisualStyleBackColor = true; buttonAddStorage.UseVisualStyleBackColor = true;
@ -149,9 +151,9 @@
// //
// buttonDeleteStorage // buttonDeleteStorage
// //
buttonDeleteStorage.Location = new Point(654, 364); buttonDeleteStorage.Location = new Point(638, 324);
buttonDeleteStorage.Name = "buttonDeleteStorage"; buttonDeleteStorage.Name = "buttonDeleteStorage";
buttonDeleteStorage.Size = new Size(150, 33); buttonDeleteStorage.Size = new Size(166, 33);
buttonDeleteStorage.TabIndex = 10; buttonDeleteStorage.TabIndex = 10;
buttonDeleteStorage.Text = "Удалить набор"; buttonDeleteStorage.Text = "Удалить набор";
buttonDeleteStorage.UseVisualStyleBackColor = true; buttonDeleteStorage.UseVisualStyleBackColor = true;
@ -159,9 +161,9 @@
// //
// textBoxStorageName // textBoxStorageName
// //
textBoxStorageName.Location = new Point(654, 103); textBoxStorageName.Location = new Point(638, 93);
textBoxStorageName.Name = "textBoxStorageName"; textBoxStorageName.Name = "textBoxStorageName";
textBoxStorageName.Size = new Size(150, 27); textBoxStorageName.Size = new Size(166, 27);
textBoxStorageName.TabIndex = 11; textBoxStorageName.TabIndex = 11;
// //
// menuStrip // menuStrip
@ -204,11 +206,33 @@
saveFileDialog.Filter = "txt file | *.txt"; saveFileDialog.Filter = "txt file | *.txt";
saveFileDialog.OverwritePrompt = false; 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 // FormAirbusCollection
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(827, 591); ClientSize = new Size(827, 585);
Controls.Add(buttonSortByColor);
Controls.Add(buttonSortByType);
Controls.Add(textBoxStorageName); Controls.Add(textBoxStorageName);
Controls.Add(buttonDeleteStorage); Controls.Add(buttonDeleteStorage);
Controls.Add(buttonAddStorage); Controls.Add(buttonAddStorage);
@ -252,5 +276,7 @@
private ToolStripMenuItem LoadToolStripMenuItem; private ToolStripMenuItem LoadToolStripMenuItem;
private OpenFileDialog openFileDialog; private OpenFileDialog openFileDialog;
private SaveFileDialog saveFileDialog; private SaveFileDialog saveFileDialog;
private Button buttonSortByType;
private Button buttonSortByColor;
} }
} }

View File

@ -29,9 +29,29 @@ namespace ProjectAirbus
_logger = logger; _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) private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (saveFileDialog.ShowDialog() == DialogResult.OK) if (saveFileDialog.ShowDialog() == DialogResult.OK)
{ {
try try
@ -75,7 +95,7 @@ namespace ProjectAirbus
listBoxStorages.Items.Clear(); listBoxStorages.Items.Clear();
for (int i = 0; i < _storage.Keys.Count; i++) 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)) if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
{ {
@ -163,6 +183,11 @@ namespace ProjectAirbus
MessageBox.Show(ex.Message); MessageBox.Show(ex.Message);
_logger.LogWarning(ex.Message); _logger.LogWarning(ex.Message);
} }
catch (Exception ex)
{
MessageBox.Show(ex.Message);
_logger.LogWarning(ex.Message);
}
} }
// удалить самолёт // удалить самолёт

View File

@ -0,0 +1,27 @@
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();
}
}

View File

@ -0,0 +1,34 @@
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);
}
}
}

View File

@ -0,0 +1,30 @@
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);
}
}
}

View File

@ -16,8 +16,8 @@ namespace ProjectAirbus.Generics
private readonly int _pictureWidth; private readonly int _pictureWidth;
private readonly int _pictureHeight; private readonly int _pictureHeight;
// Размер занимаемого места 89х34 // Размер занимаемого места 89х34
private readonly int _placeSizeWidth = 189; private readonly int _placeSizeWidth = 89;
private readonly int _placeSizeHeight = 134; private readonly int _placeSizeHeight = 34;
// коллекция // коллекция
private readonly SetGeneric<T> _collection; private readonly SetGeneric<T> _collection;
@ -31,11 +31,14 @@ namespace ProjectAirbus.Generics
_collection = new SetGeneric<T>(width * height); _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) public static int operator +(AirbusGenericCollection<T, U> collect, T? obj)
{ {
if (obj != null) if (obj != null)
{ {
return collect._collection.Insert(obj); return collect._collection.Insert(obj, new DrawningAirbusEqutables());
} }
return -1; return -1;
} }

View File

@ -13,9 +13,9 @@ namespace ProjectAirbus.Generics
internal class AirbusGenericStorage internal class AirbusGenericStorage
{ {
//Словарь (хранилище) //Словарь (хранилище)
readonly Dictionary<string, AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>> _airbusStorages; readonly Dictionary<AirbusCollectionInfo, AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>> _airbusStorages;
//Возвращение списка названий наборов //Возвращение списка названий наборов
public List<string> Keys => _airbusStorages.Keys.ToList(); public List<AirbusCollectionInfo> Keys => _airbusStorages.Keys.ToList();
//Ширина окна отрисовки //Ширина окна отрисовки
private readonly int _pictureWidth; private readonly int _pictureWidth;
//Высота окна отрисовки //Высота окна отрисовки
@ -28,10 +28,9 @@ namespace ProjectAirbus.Generics
// Разделитель для записи информации по объекту в файл // Разделитель для записи информации по объекту в файл
private static readonly char _separatorForObject = ':'; private static readonly char _separatorForObject = ':';
public AirbusGenericStorage(int pictureWidth, int pictureHeight) public AirbusGenericStorage(int pictureWidth, int pictureHeight)
{ {
_airbusStorages = new Dictionary<string, AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>>(); _airbusStorages = new Dictionary<AirbusCollectionInfo, AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>>();
_pictureWidth = pictureWidth; _pictureWidth = pictureWidth;
_pictureHeight = pictureHeight; _pictureHeight = pictureHeight;
} }
@ -39,25 +38,24 @@ namespace ProjectAirbus.Generics
// Добавление набора // Добавление набора
public void AddSet(string name) public void AddSet(string name)
{ {
// проверка, что нет набора с таким именем AirbusCollectionInfo set = new AirbusCollectionInfo(name, string.Empty);
foreach (string nameStorage in Keys)
{ if (_airbusStorages.ContainsKey(set))
if (nameStorage == name) return;
{
return; _airbusStorages.Add(set, new AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>(_pictureWidth, _pictureHeight));
}
}
_airbusStorages.Add(name, new AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>(_pictureWidth, _pictureHeight));
} }
// Удаление набора // Удаление набора
public void DelSet(string name) public void DelSet(string name)
{ {
if ( _airbusStorages.ContainsKey(name)) AirbusCollectionInfo set = new AirbusCollectionInfo(name, string.Empty);
{
_airbusStorages.Remove(name);
}
// проверка, что нет набора с таким именем
if (!_airbusStorages.ContainsKey(set))
return;
_airbusStorages.Remove(set);
} }
// Доступ к набору // Доступ к набору
@ -65,11 +63,13 @@ namespace ProjectAirbus.Generics
{ {
get get
{ {
if (_airbusStorages.ContainsKey(ind)) AirbusCollectionInfo set = new AirbusCollectionInfo(ind, string.Empty);
if (!_airbusStorages.ContainsKey(set))
{ {
return _airbusStorages[ind]; return null;
} }
return null; return _airbusStorages[set];
} }
} }
@ -162,7 +162,7 @@ namespace ProjectAirbus.Generics
} }
} }
} }
_airbusStorages.Add(record[0], collection); _airbusStorages.Add(new AirbusCollectionInfo(record[0], string.Empty), collection);
curLine = sr.ReadLine(); curLine = sr.ReadLine();
} }
} }

View File

@ -0,0 +1,57 @@
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();
}
}
}

View File

@ -23,14 +23,17 @@ namespace ProjectAirbus.Generics
_places = new List<T?>(count); _places = new List<T?>(count);
} }
// Добавление объекта в начало набора // сортировка набора
public int Insert(T airbus) public void SortSet(IComparer<T?> comparer) => _places.Sort(comparer);
// Добавление объекта в начало набора
public int Insert(T airbus, IEqualityComparer<T?>? equal = null)
{ {
return Insert(airbus, 0); return Insert(airbus, 0, equal);
} }
// Добавление объекта в набор на конкретную позицию // Добавление объекта в набор на конкретную позицию
public int Insert(T airbus, int position) public int Insert(T airbus, int position, IEqualityComparer<T?>? equal = null)
{ {
if (Count >= _maxCount) if (Count >= _maxCount)
{ {
@ -40,6 +43,11 @@ namespace ProjectAirbus.Generics
{ {
throw new IndexOutOfRangeException("Индекс вне границ коллекции"); throw new IndexOutOfRangeException("Индекс вне границ коллекции");
} }
if (equal != null && _places.Contains(airbus,equal))
{
throw new ArgumentException("Данный объект уже есть в коллекции");
}
_places.Insert(position, airbus); _places.Insert(position, airbus);
return 0; return 0;
} }
@ -55,27 +63,27 @@ namespace ProjectAirbus.Generics
return true; return true;
} }
// Получение объекта из набора по позиции // Получение объекта из набора по позиции
public T? this[int position] public T? this[int position]
{
get
{ {
get if (position < 0 || position >= Count)
{ {
if (position < 0 || position >= Count) return null;
{
return null;
}
return _places[position];
}
set
{
if (position < 0 || Count >= _maxCount)
{
return;
}
_places.Insert(position, value);
} }
return _places[position];
} }
set
{
if (position < 0 || Count >= _maxCount)
{
return;
}
_places.Insert(position, value);
}
}
// Проход по списку // Проход по списку
public IEnumerable<T?> GetAirbus(int? maxAirbus = null) public IEnumerable<T?> GetAirbus(int? maxAirbus = null)
@ -89,6 +97,5 @@ namespace ProjectAirbus.Generics
} }
} }
} }
} }
} }

View File

@ -36,9 +36,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="serilog.json"> <None Update="serilog.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>

View File

@ -1,11 +0,0 @@
<?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>