using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Text; using System.Xml; using System.Xml.Serialization; namespace das.disk { public class hrac { public List stado = new List(); public string barva; public int pozice; public int distanc; public int penize; public string jmeno; public int stop; public int typ; //1 clovek, 0 pocitac } public class sluzba { public int s; public int p; public int[] t; } public class dostih { public string jmeno; public int pocet; } [Serializable] public class hra { public List hraci = new List(); public List dostihy = new List(); public sluzba s = new sluzba(); } public class serializator { hra h; public serializator() { h = new hra(); } public void napln_hrace( List xstado, string xbarva, int xpozice, int xdistanc, int xpenize, string xjmeno, int xstop, int xtyp ) { hrac f = new hrac(); f.stado =xstado; f.barva =xbarva; f.pozice =xpozice; f.distanc =xdistanc; f.penize =xpenize; f.jmeno =xjmeno; f.stop =xstop; f.typ =xtyp; h.hraci.Add(f); } public void napln_dostihy(Hashtable dostihy) { foreach(DictionaryEntry d in dostihy) { dostih x = new dostih(); x.jmeno = (string)d.Key; x.pocet = (int)d.Value; h.dostihy.Add(x); } } public void napln_sluzby(int staje, int preprava, int[] trener) { h.s.s = staje; h.s.p = preprava; h.s.t = new int[4]; h.s.t = trener; } public void uloz(string soubor) { XmlSerializer mySerializer = new XmlSerializer(typeof(hra)); try { StreamWriter myWriter = new StreamWriter(soubor); mySerializer.Serialize(myWriter, h); myWriter.Close(); } catch { } } public hra nahraj(string soubor) { XmlSerializer nacitac = new XmlSerializer(typeof(hra)); hra h = null; try { FileStream ReadFileStream; ReadFileStream = new FileStream(soubor, FileMode.Open, FileAccess.Read, FileShare.Read); h = (hra)nacitac.Deserialize(ReadFileStream); ReadFileStream.Close(); } catch { } return h; } } }