public wMain() { InitializeComponent(); if (!System.IO.Directory.Exists(DominionBase.Utilities.Application.ApplicationPath)) System.IO.Directory.CreateDirectory(DominionBase.Utilities.Application.ApplicationPath); bTurnDone.IsEnabled = false; bPlayTreasures.Text = "Play basic _Treasures"; bPlayTreasures.IsEnabled = false; bPlayCoinTokens.IsEnabled = false; bBuyPhase.IsEnabled = false; bUndo.IsEnabled = false; cardTrash.PileName = "Trash"; _Statistics = Statistics.Load(); }
public static Statistics Load() { Statistics statistics = null; try { // TODO : This is not to be used for this release -- still some pondering to do. return new Statistics(); DataContractSerializer serializer = new DataContractSerializer(typeof(Statistics), new Type[] { }); using (FileStream fs = new FileStream(Statistics.Filename, FileMode.Open)) { using (XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(fs, new XmlDictionaryReaderQuotas())) { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (serializer.IsStartObject(reader)) { statistics = (Statistics)serializer.ReadObject(reader); } break; } } } } //using (StreamWriter swStatistics = new StreamWriter(Statistics.Filename)) //{ // using (XmlTextWriter writer = new XmlTextWriter(swStatistics)) // { // writer.Formatting = Formatting.Indented; // serializer.WriteObject(writer, this); // writer.Flush(); // } //} //XmlSerializer mySerializer = new XmlSerializer(typeof(Statistics), new Type[] { }); //FileStream myFileStream = new FileStream(Statistics.Filename, FileMode.Open); //statistics = (Statistics)mySerializer.Deserialize(myFileStream); } catch { statistics = new Statistics(); } return statistics; }