From dded2fe5dca36bc504f6ebffc19f4545bfcb32ea Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Fri, 4 Nov 2022 18:46:34 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B=20=D0=B2=20?= =?UTF-8?q?MapWithSetLocomotivesGeneric?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MapWithSetLocomotivesGeneric.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Locomotive/Locomotive/MapWithSetLocomotivesGeneric.cs b/Locomotive/Locomotive/MapWithSetLocomotivesGeneric.cs index 8f1b26e..fc6ecfa 100644 --- a/Locomotive/Locomotive/MapWithSetLocomotivesGeneric.cs +++ b/Locomotive/Locomotive/MapWithSetLocomotivesGeneric.cs @@ -158,5 +158,26 @@ namespace Locomotive } } + /// Получение данных в виде строки + public string GetData(char separatorType, char separatorData) + { + string data = $"{_map.GetType().Name}{separatorType}"; + foreach (var locomotive in _setLocomotives.GetLocomotives()) + { + data += $"{locomotive.getInfo()}{separatorData}"; + } + return data; + } + + /// Загрузка списка из массива строк + public void LoadData(string[] records) + { + foreach (var rec in records) + { + _setLocomotives.Insert(DrawningObjectLocomotive.Create(rec) as T); + } + } + + } }