2024-08-29 19:32:46 +04:00
|
|
|
|
using lab1.Entities;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace lab1.Drawnings;
|
|
|
|
|
|
|
|
|
|
public static class ExtentionDrawningTrackedVehicle
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Разделитель для записи информации по объекту в файл
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static readonly string _separatorForObject = ":";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создание объекта из строки
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info">Строка с данными для создания объекта</param>
|
|
|
|
|
/// <returns>Объект</returns>
|
2024-10-22 13:26:55 +04:00
|
|
|
|
public static DrawningTrackedVehicle? CreateDrawningTrackedVehicle(this string info)
|
2024-08-29 19:32:46 +04:00
|
|
|
|
{
|
|
|
|
|
string[] strs = info.Split(_separatorForObject);
|
2024-10-22 13:26:55 +04:00
|
|
|
|
EntityTrackedVehicle? fighter = EntityFighter.CreateEntityStormtrooper(strs);
|
2024-08-29 19:32:46 +04:00
|
|
|
|
if (fighter != null)
|
|
|
|
|
{
|
2024-10-22 13:26:55 +04:00
|
|
|
|
return new DrawningEntityFighter((EntityFighter)fighter);
|
2024-08-29 19:32:46 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fighter = EntityTrackedVehicle.CreateEntityTrackedVehicle(strs);
|
|
|
|
|
|
|
|
|
|
if (fighter != null)
|
|
|
|
|
{
|
|
|
|
|
return new DrawningTrackedVehicle(fighter);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получение данных для сохранения в файл
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="drawningStormtrooper">Сохраняемый объект</param>
|
|
|
|
|
/// <returns>Строка с данными по объекту</returns>
|
|
|
|
|
public static string GetDataForSave(this DrawningTrackedVehicle drawningBaseStormtrooper)
|
|
|
|
|
{
|
|
|
|
|
string[]? array = drawningBaseStormtrooper?.EntityTrackedVehicle?.GetStringRepresentation();
|
|
|
|
|
if (array == null)
|
|
|
|
|
{
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
return string.Join(_separatorForObject, array);
|
|
|
|
|
}
|
|
|
|
|
}
|