diff --git a/AircraftCarrier/AircraftCarrier/AircraftCarrier.csproj b/AircraftCarrier/AircraftCarrier/AircraftCarrier.csproj index 13ee123..24d34c4 100644 --- a/AircraftCarrier/AircraftCarrier/AircraftCarrier.csproj +++ b/AircraftCarrier/AircraftCarrier/AircraftCarrier.csproj @@ -8,6 +8,32 @@ enable + + + + + + + Always + + + + + + + + + + + + + + + + + + + True diff --git a/AircraftCarrier/AircraftCarrier/EntityAircraftCarrier.cs b/AircraftCarrier/AircraftCarrier/EntityAircraftCarrier.cs index d9f89c0..7585546 100644 --- a/AircraftCarrier/AircraftCarrier/EntityAircraftCarrier.cs +++ b/AircraftCarrier/AircraftCarrier/EntityAircraftCarrier.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace AircraftCarrier { - internal class EntityAircraftCarrier : EntityWarship + public class EntityAircraftCarrier : EntityWarship { /// /// Дополнительный цвет diff --git a/AircraftCarrier/AircraftCarrier/FormMapWithSetWarships.Designer.cs b/AircraftCarrier/AircraftCarrier/FormMapWithSetWarships.Designer.cs index 506e5bb..bac9473 100644 --- a/AircraftCarrier/AircraftCarrier/FormMapWithSetWarships.Designer.cs +++ b/AircraftCarrier/AircraftCarrier/FormMapWithSetWarships.Designer.cs @@ -70,9 +70,9 @@ this.groupBoxTools.Controls.Add(this.buttonUp); this.groupBoxTools.Controls.Add(this.buttonDown); this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; - this.groupBoxTools.Location = new System.Drawing.Point(754, 24); + this.groupBoxTools.Location = new System.Drawing.Point(580, 24); this.groupBoxTools.Name = "groupBoxTools"; - this.groupBoxTools.Size = new System.Drawing.Size(217, 625); + this.groupBoxTools.Size = new System.Drawing.Size(217, 547); this.groupBoxTools.TabIndex = 0; this.groupBoxTools.TabStop = false; this.groupBoxTools.Text = "Tools"; @@ -142,7 +142,7 @@ // // buttonShowOnMap // - this.buttonShowOnMap.Location = new System.Drawing.Point(20, 516); + this.buttonShowOnMap.Location = new System.Drawing.Point(20, 437); this.buttonShowOnMap.Name = "buttonShowOnMap"; this.buttonShowOnMap.Size = new System.Drawing.Size(180, 35); this.buttonShowOnMap.TabIndex = 18; @@ -152,7 +152,7 @@ // // buttonShowStorage // - this.buttonShowStorage.Location = new System.Drawing.Point(20, 475); + this.buttonShowStorage.Location = new System.Drawing.Point(20, 396); this.buttonShowStorage.Name = "buttonShowStorage"; this.buttonShowStorage.Size = new System.Drawing.Size(180, 35); this.buttonShowStorage.TabIndex = 17; @@ -162,7 +162,7 @@ // // buttonRemoveWarship // - this.buttonRemoveWarship.Location = new System.Drawing.Point(20, 434); + this.buttonRemoveWarship.Location = new System.Drawing.Point(20, 355); this.buttonRemoveWarship.Name = "buttonRemoveWarship"; this.buttonRemoveWarship.Size = new System.Drawing.Size(180, 35); this.buttonRemoveWarship.TabIndex = 16; @@ -172,7 +172,7 @@ // // maskedTextBoxPosition // - this.maskedTextBoxPosition.Location = new System.Drawing.Point(20, 405); + this.maskedTextBoxPosition.Location = new System.Drawing.Point(20, 326); this.maskedTextBoxPosition.Mask = "00"; this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; this.maskedTextBoxPosition.Size = new System.Drawing.Size(180, 23); @@ -181,7 +181,7 @@ // // buttonAddWarship // - this.buttonAddWarship.Location = new System.Drawing.Point(20, 364); + this.buttonAddWarship.Location = new System.Drawing.Point(20, 285); this.buttonAddWarship.Name = "buttonAddWarship"; this.buttonAddWarship.Size = new System.Drawing.Size(180, 35); this.buttonAddWarship.TabIndex = 14; @@ -194,7 +194,7 @@ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.BackgroundImage = global::AircraftCarrier.Properties.Resources.ArrowRight; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(126, 594); + this.buttonRight.Location = new System.Drawing.Point(126, 516); this.buttonRight.Name = "buttonRight"; this.buttonRight.Size = new System.Drawing.Size(30, 30); this.buttonRight.TabIndex = 13; @@ -207,7 +207,7 @@ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.BackgroundImage = global::AircraftCarrier.Properties.Resources.ArrowLeft; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(54, 594); + this.buttonLeft.Location = new System.Drawing.Point(54, 516); this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Size = new System.Drawing.Size(30, 30); this.buttonLeft.TabIndex = 12; @@ -220,7 +220,7 @@ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonUp.BackgroundImage = global::AircraftCarrier.Properties.Resources.ArrowUp; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonUp.Location = new System.Drawing.Point(90, 558); + this.buttonUp.Location = new System.Drawing.Point(90, 480); this.buttonUp.Name = "buttonUp"; this.buttonUp.Size = new System.Drawing.Size(30, 30); this.buttonUp.TabIndex = 11; @@ -233,7 +233,7 @@ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.BackgroundImage = global::AircraftCarrier.Properties.Resources.ArrowDown; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(90, 594); + this.buttonDown.Location = new System.Drawing.Point(90, 516); this.buttonDown.Name = "buttonDown"; this.buttonDown.Size = new System.Drawing.Size(30, 30); this.buttonDown.TabIndex = 10; @@ -246,7 +246,7 @@ this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBox.Location = new System.Drawing.Point(0, 24); this.pictureBox.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(754, 625); + this.pictureBox.Size = new System.Drawing.Size(580, 547); this.pictureBox.TabIndex = 1; this.pictureBox.TabStop = false; // @@ -256,7 +256,7 @@ this.fileToolStripMenuItem}); this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Name = "menuStrip"; - this.menuStrip.Size = new System.Drawing.Size(971, 24); + this.menuStrip.Size = new System.Drawing.Size(797, 24); this.menuStrip.TabIndex = 2; // // fileToolStripMenuItem @@ -294,7 +294,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(971, 649); + this.ClientSize = new System.Drawing.Size(797, 571); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBoxTools); this.Controls.Add(this.menuStrip); diff --git a/AircraftCarrier/AircraftCarrier/FormMapWithSetWarships.cs b/AircraftCarrier/AircraftCarrier/FormMapWithSetWarships.cs index db58c0f..9b0dcc5 100644 --- a/AircraftCarrier/AircraftCarrier/FormMapWithSetWarships.cs +++ b/AircraftCarrier/AircraftCarrier/FormMapWithSetWarships.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.Extensions.Logging; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -26,11 +27,16 @@ namespace AircraftCarrier /// private readonly MapsCollection _mapsCollection; /// + /// Логер + /// + private readonly ILogger _logger; + /// /// Конструктор /// - public FormMapWithSetWarships() + public FormMapWithSetWarships(ILogger logger) { InitializeComponent(); + _logger = logger; _mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height); comboBoxSelectorMap.Items.Clear(); foreach (var elem in _mapsDict) @@ -70,15 +76,18 @@ namespace AircraftCarrier if (comboBoxSelectorMap.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxNewMapName.Text)) { MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogInformation("При добавлении карты {0}", comboBoxSelectorMap.SelectedIndex == -1 ? "Не была выбрана карта" : "Не была названа карта"); return; } if (!_mapsDict.ContainsKey(comboBoxSelectorMap.Text)) { MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogWarning("Нет карты с названием: {0}", textBoxNewMapName.Text); return; } _mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]); ReloadMaps(); + _logger.LogInformation("Добавлена карта {0}", textBoxNewMapName.Text); } /// /// Выбор карты @@ -88,6 +97,7 @@ namespace AircraftCarrier private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e) { pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + _logger.LogInformation("Был осуществлен переход на карту под названием: {0}", listBoxMaps.SelectedItem?.ToString() ?? string.Empty); } /// /// Удаление карты @@ -104,6 +114,7 @@ namespace AircraftCarrier if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty); + _logger.LogInformation("Удалена карта {0}", listBoxMaps.SelectedItem?.ToString() ?? string.Empty); ReloadMaps(); } } @@ -125,22 +136,31 @@ namespace AircraftCarrier /// private void AddWarshipOnForm(DrawingWarship drawningWarship) { - if (listBoxMaps.SelectedIndex == -1) + try { - return; + if (listBoxMaps.SelectedIndex == -1) + { + MessageBox.Show("Перед добавлением объекта необходимо создать карту"); + } + DrawingObjectWarship warship = new(drawningWarship); + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + warship >= 0) + { + _logger.LogInformation($"Добавлен объект {warship}"); + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + _logger.LogInformation("Не удалось добавить объект"); + } } - - DrawingObjectWarship warship = new(drawningWarship); - if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + warship >= 0) - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); - } - else + catch(StorageOverflowException ex) { MessageBox.Show("Не удалось добавить объект"); + _logger.LogWarning("Ошибка переполнения хранилища: {0}", ex.Message); + MessageBox.Show($"Ошибка переполнения хранилища: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); } - } /// /// Удаление объекта @@ -149,27 +169,31 @@ namespace AircraftCarrier /// private void ButtonRemoveWarship_Click(object sender, EventArgs e) { - if (listBoxMaps.SelectedIndex == -1) - { - return; - } - if (string.IsNullOrEmpty(maskedTextBoxPosition.Text)) - { - return; - } - if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + if (listBoxMaps.SelectedIndex == -1 || string.IsNullOrEmpty(maskedTextBoxPosition.Text) || + MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } int pos = Convert.ToInt32(maskedTextBoxPosition.Text); - if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null) + try { - MessageBox.Show("Объект удален"); - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + var deletedWarship = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos; + if (deletedWarship != null) + { + _logger.LogInformation($"Объект {deletedWarship} удалён"); + MessageBox.Show("Объект удален"); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + _logger.LogInformation("Не удалось добавить объект по позиции {0} равен null", pos); + } } - else + catch (WarshipNotFoundException ex) { - MessageBox.Show("Не удалось удалить объект"); + MessageBox.Show($"Ошибка удаления: {ex.Message}"); + _logger.LogWarning("Ошибка удаления: {0}", ex.Message); } } /// @@ -238,13 +262,16 @@ namespace AircraftCarrier { if (saveFileDialog.ShowDialog() == DialogResult.OK) { - if (_mapsCollection.SaveData(saveFileDialog.FileName)) + try { + _mapsCollection.SaveData(saveFileDialog.FileName); + _logger.LogInformation("Сохранение прошло успешно. Файл находится: {0}", saveFileDialog.FileName); MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); } - else + catch(Exception ex) { - MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogWarning("Не удалось сохранить файл '{0}'. Текст ошибки: {1}", saveFileDialog.FileName, ex.Message); + MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } @@ -257,14 +284,17 @@ namespace AircraftCarrier { if(openFileDialog.ShowDialog() == DialogResult.OK) { - if (_mapsCollection.LoadData(openFileDialog.FileName)) + try { - MessageBox.Show("Загрузка прошла успешно!", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + _mapsCollection.LoadData(openFileDialog.FileName); + _logger.LogInformation("Открытие файла '{0}' прошло успешно", openFileDialog.FileName); + MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); ReloadMaps(); } - else + catch (Exception ex) { - MessageBox.Show("Не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + _logger.LogWarning("Не удалось открыть файл {0}. Текст ошибки: {1}", openFileDialog.FileName, ex.Message); + MessageBox.Show($"Не удалось открыть: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } diff --git a/AircraftCarrier/AircraftCarrier/MapWithSetWarshipsGeneric.cs b/AircraftCarrier/AircraftCarrier/MapWithSetWarshipsGeneric.cs index e2eb3cd..45b41d5 100644 --- a/AircraftCarrier/AircraftCarrier/MapWithSetWarshipsGeneric.cs +++ b/AircraftCarrier/AircraftCarrier/MapWithSetWarshipsGeneric.cs @@ -149,10 +149,10 @@ namespace AircraftCarrier { for (; j > i; j--) { - var car = _setWarships[j]; - if (car != null) + var warship = _setWarships[j]; + if (warship != null) { - _setWarships.Insert(car, i); + _setWarships.Insert(warship, i); _setWarships.Remove(j); break; } @@ -189,12 +189,14 @@ namespace AircraftCarrier /// private void DrawWarships(Graphics g) { - int width = _pictureWidth / _placeSizeWidth; - int height = _pictureHeight / _placeSizeHeight; + int countInLine = _pictureWidth / _placeSizeWidth; + int countInColumn = _pictureHeight / _placeSizeHeight; + + int maxDown = (countInColumn - 1) * _placeSizeHeight; for (int i = 0; i < _setWarships.Count; i++) { var warship = _setWarships[i]; - warship?.SetObject(i % _pictureWidth * _placeSizeWidth, (height - 1 - i / width) * _placeSizeHeight + 4, _pictureWidth, _pictureHeight); + warship?.SetObject(i % countInLine * _placeSizeWidth, maxDown - i / countInLine * _placeSizeHeight + 7, _pictureWidth, _pictureHeight); warship?.DrawningObject(g); } } diff --git a/AircraftCarrier/AircraftCarrier/MapsCollection.cs b/AircraftCarrier/AircraftCarrier/MapsCollection.cs index 618549b..1eb5145 100644 --- a/AircraftCarrier/AircraftCarrier/MapsCollection.cs +++ b/AircraftCarrier/AircraftCarrier/MapsCollection.cs @@ -74,21 +74,11 @@ namespace AircraftCarrier } } /// - /// Метод записи информации в файл - /// - /// Строка, которую следует записать - /// Поток для записи - private static void WriteToFile(string text, FileStream stream) - { - byte[] info = new UTF8Encoding(true).GetBytes(text); - stream.Write(info, 0, info.Length); - } - /// /// Сохранение информации по кораблям в хранилище в файл /// /// Путь и имя файла /// - public bool SaveData(string filename) + public void SaveData(string filename) { if (File.Exists(filename)) { @@ -102,7 +92,6 @@ namespace AircraftCarrier sw.Write($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}{Environment.NewLine}"); } } - return true; } /// @@ -110,18 +99,18 @@ namespace AircraftCarrier /// /// /// - public bool LoadData(string filename) + public void LoadData(string filename) { if (!File.Exists(filename)) { - return false; + throw new FileNotFoundException("Файл не найден"); } using (StreamReader sr = new(filename)) { string str = ""; if ((str = sr.ReadLine()) == null || !str.Contains("MapsCollection")) { - return false; + throw new FileFormatException("Формат данных в файле не правильный"); } _mapStorages.Clear(); while ((str = sr.ReadLine()) != null) @@ -141,7 +130,6 @@ namespace AircraftCarrier _mapStorages[elem[0]].LoadData(elem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); } } - return true; } } } diff --git a/AircraftCarrier/AircraftCarrier/Program.cs b/AircraftCarrier/AircraftCarrier/Program.cs index 00b84f4..93e06e7 100644 --- a/AircraftCarrier/AircraftCarrier/Program.cs +++ b/AircraftCarrier/AircraftCarrier/Program.cs @@ -1,3 +1,8 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Serilog; + namespace AircraftCarrier { internal static class Program @@ -11,7 +16,32 @@ namespace AircraftCarrier // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormMapWithSetWarships()); + var services = new ServiceCollection(); + ConfigureServices(services); + using (ServiceProvider serviceProvider = services.BuildServiceProvider()) + { + Application.Run(serviceProvider.GetRequiredService()); + } + } + + private static void ConfigureServices(ServiceCollection services) + { + services.AddSingleton() + .AddLogging(option => + { + var configuration = new ConfigurationBuilder() + + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile(path: "jsconfig.json", optional: false, reloadOnChange: true) + .Build(); + + var logger = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .CreateLogger(); + + option.SetMinimumLevel(LogLevel.Information); + option.AddSerilog(logger); + }); } } } \ No newline at end of file diff --git a/AircraftCarrier/AircraftCarrier/SetWarshipsGeneric.cs b/AircraftCarrier/AircraftCarrier/SetWarshipsGeneric.cs index 5aba52c..b896fc5 100644 --- a/AircraftCarrier/AircraftCarrier/SetWarshipsGeneric.cs +++ b/AircraftCarrier/AircraftCarrier/SetWarshipsGeneric.cs @@ -49,10 +49,19 @@ namespace AircraftCarrier /// public int Insert(T warship, int position) { - if (position >= _maxCount || position < 0) return -1; + if (Count == _maxCount) + throw new StorageOverflowException(_maxCount); + + if (!isCorrectPosition(position)) return -1; _places.Insert(position, warship); return 1; } + + private bool isCorrectPosition(int position) + { + return 0 <= position && position < _maxCount; + } + /// /// Удаление объекта из набора с конкретной позиции /// @@ -60,10 +69,11 @@ namespace AircraftCarrier /// public T Remove(int position) { - if (position >= _maxCount || position < 0) + if (!isCorrectPosition(position)) return null; - - var result = _places[position]; + var result = this[position]; + if (result == null) + throw new WarshipNotFoundException(position); _places.RemoveAt(position); return result; } @@ -76,8 +86,7 @@ namespace AircraftCarrier { get { - if (position >= _maxCount || position < 0) return null; - return _places[position]; + return isCorrectPosition(position) && position < Count ? _places[position] : null; } set { diff --git a/AircraftCarrier/AircraftCarrier/StorageOverflowException.cs b/AircraftCarrier/AircraftCarrier/StorageOverflowException.cs new file mode 100644 index 0000000..d6f6a32 --- /dev/null +++ b/AircraftCarrier/AircraftCarrier/StorageOverflowException.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace AircraftCarrier +{ + [Serializable] + internal class StorageOverflowException : ApplicationException + { + public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: {count}") { } + public StorageOverflowException() : base() { } + public StorageOverflowException(string message) : base(message) { } + public StorageOverflowException(string message, Exception exception) : base(message, exception) { } + protected StorageOverflowException(SerializationInfo info, StreamingContext contex) : base(info, contex) { } + } +} diff --git a/AircraftCarrier/AircraftCarrier/WarshipNotFoundException.cs b/AircraftCarrier/AircraftCarrier/WarshipNotFoundException.cs new file mode 100644 index 0000000..40638c3 --- /dev/null +++ b/AircraftCarrier/AircraftCarrier/WarshipNotFoundException.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace AircraftCarrier +{ + [Serializable] + internal class WarshipNotFoundException : ApplicationException + { + public WarshipNotFoundException(int i) : base($"Не найден объект по позиции {i}") { } + public WarshipNotFoundException() : base() { } + public WarshipNotFoundException(string message) : base(message) { } + public WarshipNotFoundException(string message, Exception exception) : base(message, exception) { } + protected WarshipNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { } + } +} diff --git a/AircraftCarrier/AircraftCarrier/jsconfig.json b/AircraftCarrier/AircraftCarrier/jsconfig.json new file mode 100644 index 0000000..34cb0da --- /dev/null +++ b/AircraftCarrier/AircraftCarrier/jsconfig.json @@ -0,0 +1,48 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.File" ], + "MinimumLevel": "Information", + "WriteTo": [ + { + "Name": "File", + "Args": { + "path": "Logs/log_.log", + "rollingInterval": "Day", + "outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}" + } + } + ], + "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ], + "Destructure": [ + { + "Name": "ByTransforming", + "Args": { + "returnType": "AircraftCarrier.EntityWarship", + "transformation": "r => new { BodyColor = r.BodyColor.Name, r.Speed, r.Weight }" + } + }, + { + "Name": "ByTransforming", + "Args": { + "returnType": "AircraftCarrier.EntityAircraftCarrier", + "transformation": "r => new { BodyColor = r.BodyColor.Name, DopColor = r.DopColor, r.BodyKit, r.Сabin, r.SuperEngine, r.Speed, r.Weight }" + } + }, + { + "Name": "ToMaximumDepth", + "Args": { "maximumDestructuringDepth": 4 } + }, + { + "Name": "ToMaximumStringLength", + "Args": { "maximumStringLength": 100 } + }, + { + "Name": "ToMaximumCollectionCount", + "Args": { "maximumCollectionCount": 10 } + } + ], + "Properties": { + "Application": "AircraftCarrier" + } + } +} \ No newline at end of file