/// <summary>Deserializes to an instance of GameCatalog.</summary> /// <param name="reader">TextReader instance.</param> /// <returns>GameCatalog result.</returns> public GameCatalog Deserialize(TextReader reader) { GameCatalog o = (GameCatalog)s.Deserialize(reader); reader.Close(); return(o); }
private string StringSerialize(GameCatalog gamecatalog) { TextWriter w = WriterSerialize(gamecatalog); string xml = w.ToString(); w.Close(); return(xml); }
private TextWriter WriterSerialize(GameCatalog gamecatalog) { TextWriter w = new StringWriter(); this.s = new XmlSerializer(this.type); s.Serialize(w, gamecatalog); w.Flush(); return(w); }
/// <summary>Serializes to an XmlDocument.</summary> /// <param name="GameCatalog">GameCatalog to serialize.</param> /// <returns>XmlDocument instance.</returns> public XmlDocument Serialize(GameCatalog gamecatalog) { string xml = StringSerialize(gamecatalog); XmlDocument doc = new XmlDocument(); doc.PreserveWhitespace = true; doc.LoadXml(xml); doc = Clean(doc); return(doc); }
/// <summary>Writes config data to config file.</summary> /// <param name="file">Config file name.</param> /// <param name="config">Config object.</param> /// <returns></returns> public static bool WriteFile(string file, GameCatalog config) { bool ok = false; GameCatalogSerializer serializer = new GameCatalogSerializer(); try { string xml = serializer.Serialize(config).OuterXml; using (StreamWriter writer = new StreamWriter(file, false)) { writer.Write(xml); writer.Flush(); writer.Close(); } ok = true; } catch {} return(ok); }
// File New private void menuItem12_Click(object sender, System.EventArgs e) { if (dirty) { DialogResult dr = MessageBox.Show(this, "Data changed, would you like to save?", "Save", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { menuItem10_Click(sender, e); } else if (dr == DialogResult.Cancel) { return; } } games = new GameCatalog(); filename = null; gamelist.Items.Clear(); }
public Form1() { InitializeComponent(); PaintMenu(); games = new GameCatalog(); }
private void OpenFile(string filename) { this.filename = filename; games = GameCatalogSerializer.ReadFile(filename); dirty = false; }
public PrintForm2(Games games) : this() { this.games = new GameCatalog(); this.games.Games = games; Init(); }
public PrintForm2(GameCatalog gcat) : this() { this.games = gcat; Init(); }
public StatsForm(GameCatalog game) { InitializeComponent(); this.game = game; UpdateUI(); }