diff --git a/ClassLib000/Walker/Appartment.cs b/ClassLib000/Walker/Appartment.cs index 8e93c4b..29b3443 100644 --- a/ClassLib000/Walker/Appartment.cs +++ b/ClassLib000/Walker/Appartment.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Text; @@ -18,6 +19,19 @@ namespace ClassLib000.Walker } #region public methods + /// + /// Формирование содержимого для сохранения (сериализация) + /// + public string GetContent() + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine($"{VC.GetContent()}"); + foreach (CleanSpace space in CleanSpaces) + { + sb.AppendLine($"{space.GetContent()}"); + } + return sb.ToString(); + } public void InitDoor(int x1, int y1, int x2, int y2) { diff --git a/ClassLib000/Walker/CleanSpace.cs b/ClassLib000/Walker/CleanSpace.cs index 8ce0444..4246dd2 100644 --- a/ClassLib000/Walker/CleanSpace.cs +++ b/ClassLib000/Walker/CleanSpace.cs @@ -27,5 +27,10 @@ namespace ClassLib000.Walker this.Y = y1; DateClean = DateTime.Now.AddYears(-1); } + + internal object GetContent() + { + return $"{X};{Y};{DateClean:yyyy.MM.dd};{(int)CleanType};{WallNorth};{WallSouth}..."; + } } } diff --git a/ClassLib000/Walker/VacuumCleaner.cs b/ClassLib000/Walker/VacuumCleaner.cs index ba8d86c..5db8226 100644 --- a/ClassLib000/Walker/VacuumCleaner.cs +++ b/ClassLib000/Walker/VacuumCleaner.cs @@ -20,5 +20,10 @@ namespace ClassLib000.Walker { return true; } + + internal object GetContent() + { + return $"{X};{Y};{(int)Mode}"; + } } } diff --git a/ConsoleCore/RobotFiler.cs b/ConsoleCore/RobotFiler.cs new file mode 100644 index 0000000..0703be4 --- /dev/null +++ b/ConsoleCore/RobotFiler.cs @@ -0,0 +1,20 @@ +using ClassLib000.Walker; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleCore +{ + class RobotFiler + { + internal static void SaveFile(string sFileName, Appartment app) + { + File.WriteAllText(sFileName, app.GetContent(), Encoding.UTF8); + // byte[] bt = Encoding.UTF8.GetBytes(app.GetContent()); + // File.WriteAllBytes(sFileName, bt); + } + } +}