示例#1
0
        private void ReadXml()
        {
            data = new XMLDataHandler();
            string filename = GetFileName("xml");

            if (filename == null)
            {
                return;
            }
            try
            {
                _baseDocument       = data.LoadXML(filename);
                _generatedXDocument = new XDocument(_baseDocument);
            }
            catch (Exception ex)
            {
                SweetAlert.Show("Error while reading file:", ex.Message, msgImage: SweetAlertImage.ERROR);
            }

            _schemaPath = GetFileName("xsd");
            try
            {
                XMLValidator.ValidateSchema("http://www.gamelib.org/types", _schemaPath, _baseDocument);
            }
            catch (Exception ex)
            {
                SweetAlert.Show("XSD Schema validation error:", ex.Message, msgImage: SweetAlertImage.ERROR);
            }

            GameLibrary     = data.GameLibrary;
            BaseGameLibrary = new GameLibrary(GameLibrary);
            UpdateIds();
            RaisePropertyChanged("GamesIds");
        }
示例#2
0
        private void ValidateXml()
        {
            if (null == data.GameLibrary)
            {
                return;
            }

            try
            {
                _generatedXDocument = data.CreateXDocument();
                _schemaPath         = GetFileName("xsd");
                XMLValidator.ValidateSchema("http://www.gamelib.org/types", _schemaPath, _generatedXDocument);
            }
            catch (XmlSchemaValidationException ex)
            {
                SweetAlert.Show("XSD Schema validation error:", ex.Message, msgImage: SweetAlertImage.ERROR);
            }
            catch (Exception ex)
            {
                SweetAlert.Show("Model error:", ex.Message, msgImage: SweetAlertImage.ERROR);
            }
        }