public MainWindow() { InitializeComponent(); Biblioteka = new Biblioteka(); XML = new XmlManager(@"../../Data/biblioteka.xml", @"../../Data/biblioteka.xsd", @"../../Data/txt.xsl", @"../../Data/txt.txt"); TabControl.SelectedIndex = 3; OpenApplication(); }
public void SaveData(Biblioteka biblioteka) { if (XmlFile.Exists) { XmlFile.Delete(); } Stream stream = new FileStream(XmlFile.FullName, FileMode.Create); Serializer.Serialize(stream, biblioteka); stream.Close(); }
public void SaveCopy(Biblioteka biblioteka) { FileInfo tmp = new FileInfo("copy.xml"); if (tmp.Exists) { tmp.Delete(); } Stream stream = new FileStream(tmp.FullName, FileMode.Create); Serializer.Serialize(stream, biblioteka); stream.Close(); }
public bool ValidateXmlSchema(Biblioteka biblioteka) { try { SaveCopy(biblioteka); XmlDocument xmld = new XmlDocument(); string xmlText = File.ReadAllText("copy.xml"); xmld.LoadXml(xmlText); xmld.Schemas.Add("http://www.example.org/typy", SchemaFile.FullName); xmld.Validate(ValidationCallBack); return(true); } catch { return(false); } }
public Biblioteka LoadData() { Biblioteka biblioteka = null; if (XmlFile.Exists) { using (TextReader textReader = new StreamReader(XmlFile.FullName)) { biblioteka = (Biblioteka)Serializer.Deserialize(textReader); textReader.Close(); } } else { throw new IOException(); } return(biblioteka); }