2024-04-30 11:26:54 +04:00
|
|
|
|
using ProjectStormtrooper.Entities;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace ProjectStormtrooper.Drawnings
|
|
|
|
|
{
|
2024-05-16 21:57:38 +04:00
|
|
|
|
public static class ExtentionDrawningStormtrooperBase
|
2024-04-30 11:26:54 +04:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Разделитель для записи информации по объекту в файл
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static readonly string _separatorForObject = ":";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создание объекта из строки
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="info">Строка с данными для создания объекта</param>
|
|
|
|
|
/// <returns>Объект</returns>
|
|
|
|
|
public static DrawningStormtrooperBase? CreateDrawningStormtrooper(this string info)
|
|
|
|
|
{
|
|
|
|
|
string[] strs = info.Split(_separatorForObject);
|
|
|
|
|
EntityStormtrooperBase? stormtrooper = EntityStormtrooper.CreateEntityStormtrooper(strs);
|
|
|
|
|
if (stormtrooper != null)
|
|
|
|
|
{
|
|
|
|
|
return new DrawingStormtrooper((EntityStormtrooper)stormtrooper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stormtrooper = EntityStormtrooperBase.CreateEntityBaseStormtrooper(strs);
|
|
|
|
|
|
|
|
|
|
if (stormtrooper != null)
|
|
|
|
|
{
|
|
|
|
|
return new DrawningStormtrooperBase(stormtrooper);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получение данных для сохранения в файл
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="drawningStormtrooper">Сохраняемый объект</param>
|
|
|
|
|
/// <returns>Строка с данными по объекту</returns>
|
|
|
|
|
public static string GetDataForSave(this DrawningStormtrooperBase drawningBaseStormtrooper)
|
|
|
|
|
{
|
|
|
|
|
string[]? array = drawningBaseStormtrooper?.EntityStormtrooperBase?.GetStringRepresentation();
|
|
|
|
|
if (array == null)
|
|
|
|
|
{
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
return string.Join(_separatorForObject, array);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|