Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
1 create a class for the session
2 make an ObjectDataSource based on it
3 bind the controls to the fields
4 Serialize
[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);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question