1 создать класс для сеанса
2 на основе его сделать ObjectDataSource
3 забиндить контролы на поля
4 Сериализовать
[Serializable]
public class FilmShow
{
[Serializable]
public class Place
{
public Place() { }
public int? UserId { get; set; }
public bool IsReserved { get; set; }
}
[Serializable]
public class Row
{
public Row() { }
public Place[] Places { get; set; }
}
public DateTime Date { get; set; }
public string Name { get; set; }
public Row[] Rows { get; set; }
public FilmShow()
{
}
public FilmShow(DateTime date, string name, int row, int column)
{
Date = date;
Name = name;
Rows = new Row[row];
for (var i = 0; i < Rows.Length; i++)
{
var item = new Row() { Places = new Place[column] };
for (var j = 0; j < item.Places.Length; j++)
{
item.Places[j] = new Place();
}
Rows[i] = item;
}
}
public static void Save(FilmShow filmShow, string path)
{
var formatter = new XmlSerializer(typeof(FilmShow));
using var fs = new FileStream(path, FileMode.OpenOrCreate);
formatter.Serialize(fs, filmShow);
}
public static FilmShow Load(string path)
{
var formatter = new XmlSerializer(typeof(FilmShow));
using var fs = new FileStream(path, FileMode.OpenOrCreate);
return (FilmShow)formatter.Deserialize(fs);
}
}