コード例 #1
0
        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();
        }
コード例 #2
0
        public void SaveData(Biblioteka biblioteka)
        {
            if (XmlFile.Exists)
            {
                XmlFile.Delete();
            }

            Stream stream = new FileStream(XmlFile.FullName, FileMode.Create);

            Serializer.Serialize(stream, biblioteka);
            stream.Close();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        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);
        }