Добавление метода в класс-коллекцию

This commit is contained in:
Андрей Байгулов 2023-11-26 23:12:10 +04:00
parent db78391b7f
commit 127a678e28
2 changed files with 10 additions and 8 deletions

View File

@ -24,17 +24,17 @@ namespace ProjectElectricLocomotive.DrawingObjects
if (strs.Length == 3) if (strs.Length == 3)
{ {
return new DrawingLocomotive(Convert.ToInt32(strs[0]), return new DrawingLocomotive(Convert.ToInt32(strs[0]),
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height); Convert.ToInt32(strs[1]),
Color.FromName(strs[2]), width, height);
} }
if (strs.Length == 7) if (strs.Length == 6)
{ {
return new DrawningSportCar(Convert.ToInt32(strs[0]), return new DrawingElectricLocomotive(Convert.ToInt32(strs[0]),
Convert.ToInt32(strs[1]), Convert.ToInt32(strs[1]),
Color.FromName(strs[2]), Color.FromName(strs[2]),
Color.FromName(strs[3]), Color.FromName(strs[3]),
Convert.ToBoolean(strs[4]), Convert.ToBoolean(strs[4]),
Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[5]), width, height);
Convert.ToBoolean(strs[6]), width, height);
} }
return null; return null;
} }
@ -44,8 +44,7 @@ namespace ProjectElectricLocomotive.DrawingObjects
/// <param name="drawningCar">Сохраняемый объект</param> /// <param name="drawningCar">Сохраняемый объект</param>
/// <param name="separatorForObject">Разделитель даннных</param> /// <param name="separatorForObject">Разделитель даннных</param>
/// <returns>Строка с данными по объекту</returns> /// <returns>Строка с данными по объекту</returns>
public static string GetDataForSave(this DrawingLocomotive drawningCar, public static string GetDataForSave(this DrawingLocomotive drawningCar, char separatorForObject)
char separatorForObject)
{ {
var loco = drawningCar.EntityLocomotive; var loco = drawningCar.EntityLocomotive;
if (loco == null) if (loco == null)
@ -61,6 +60,5 @@ namespace ProjectElectricLocomotive.DrawingObjects
return return
$"{str}{separatorForObject}{electricLocomotive.AdditionalColor.Name}{separatorForObject}{electricLocomotive.Pantograph}{separatorForObject}{electricLocomotive.Compartment}"; $"{str}{separatorForObject}{electricLocomotive.AdditionalColor.Name}{separatorForObject}{electricLocomotive.Pantograph}{separatorForObject}{electricLocomotive.Compartment}";
} }
} }
} }

View File

@ -87,5 +87,9 @@ namespace ProjectElectricLocomotive.Generics
} }
} }
} }
/// <summary>
/// Получение объектов коллекции
/// </summary>
public IEnumerable<T?> GetLocomotives => _collection.GetLocomotives();
} }
} }