Browse Source

File.WriteAllN

master
2 1 month ago
parent
commit
28396a8bf4
  1. 14
      ClassLib000/Walker/Appartment.cs
  2. 5
      ClassLib000/Walker/CleanSpace.cs
  3. 5
      ClassLib000/Walker/VacuumCleaner.cs
  4. 20
      ConsoleCore/RobotFiler.cs

14
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
/// <summary>
/// Формирование содержимого для сохранения (сериализация)
/// </summary>
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)
{

5
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}...";
}
}
}

5
ClassLib000/Walker/VacuumCleaner.cs

@ -20,5 +20,10 @@ namespace ClassLib000.Walker
{
return true;
}
internal object GetContent()
{
return $"{X};{Y};{(int)Mode}";
}
}
}

20
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);
}
}
}
Loading…
Cancel
Save