Пример #1
0
        public void SaveData(płytoteka płytoteka)
        {
            if (XmlFile.Exists)
            {
                XmlFile.Delete();
            }

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

            Serializer.Serialize(stream, płytoteka);
            stream.Close();
        }
Пример #2
0
        public void SaveCopy(płytoteka płytoteka)
        {
            FileInfo tmp = new FileInfo("Dokumenty//XmlCopy.xml");

            if (tmp.Exists)
            {
                tmp.Delete();
            }

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

            Serializer.Serialize(stream, płytoteka);
            stream.Close();
        }
Пример #3
0
        public płytoteka LoadData()
        {
            płytoteka płytoteka = null;

            if (XmlFile.Exists)
            {
                using (TextReader textReader = new StreamReader(XmlFile.FullName))
                {
                    płytoteka = (płytoteka)Serializer.Deserialize(textReader);
                    textReader.Close();
                }
            }
            else
            {
                throw new IOException();
            }

            return(płytoteka);
        }
Пример #4
0
        //    public bool ValidateXmlSchema(płytoteka płytoteka)
        //    {
        //        SaveCopy(płytoteka);
        //        XmlDocument x = new XmlDocument();
        //        x.LoadXml(XmlFile.FullName);

        //        XmlReaderSettings settings = new XmlReaderSettings();
        //        settings.CloseInput = true;
        //        settings.ValidationEventHandler += Handler;

        //        settings.ValidationType = ValidationType.Schema;
        //        settings.Schemas.Add(null, ExtendedTreeViewSchema);
        //        settings.ValidationFlags =
        //             XmlSchemaValidationFlags.ReportValidationWarnings |
        //        XmlSchemaValidationFlags.ProcessIdentityConstraints |
        //        XmlSchemaValidationFlags.ProcessInlineSchema |
        //        XmlSchemaValidationFlags.ProcessSchemaLocation;

        //        StringReader r = new StringReader(XmlSource);

        //        using (XmlReader validatingReader = XmlReader.Create(r, settings))
        //        {
        //            while (validatingReader.Read()) { /* just loop through document */ }
        //        }
        //    }

        //    private static void Handler(object sender, ValidationEventArgs e)
        //    {

        //        if (e.Severity == XmlSeverityType.Error || e.Severity ==
        //XmlSeverityType.Warning)
        //            System.Diagnostics.Trace.WriteLine(
        //              String.Format("Line: {0}, Position: {1} \"{2}\"",
        //                  e.Exception.LineNumber, e.Exception.LinePosition,
        //  e.Exception.Message));

        //    }

        public bool ValidateXmlSchema(płytoteka płytoteka)
        {
            try
            {
                SaveCopy(płytoteka);

                XmlDocument xmld    = new XmlDocument();
                string      xmlText = File.ReadAllText("Dokumenty//XmlCopy.xml");
                xmld.LoadXml(xmlText);
                xmld.Schemas.Add("http://tempuri.org/HeaderNamespace", SchemaFile[0].FullName);
                xmld.Schemas.Add("http://tempuri.org/NumericalTypesNamespace", SchemaFile[1].FullName);
                xmld.Schemas.Add("http://tempuri.org/OurNamespace", SchemaFile[2].FullName);
                xmld.Validate(ValidationCallBack);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #5
0
        public MainWindow()
        {
            InitializeComponent();

            Edit.IsEnabled     = false;
            Save.IsEnabled     = false;
            Cancel.IsEnabled   = false;
            EditSave.IsEnabled = false;

            SetEnabledBoxes(false);

            płytoteka = new płytoteka();

            XmlUtilities = new XmlUtilities("Dokumenty//plytoteka.xml", new string[3] {
                "Dokumenty//HeaderNamespace.xsd", "Dokumenty//NumericalTypesNamespace.xsd", "Dokumenty//OurNamespace.xsd"
            });

            OpenApplication();

            płytyListView.ItemsSource  = płytyCollection;
            walutaComboBox.ItemsSource = Enum.GetValues(typeof(cenaWaluta));
            comboBox.ItemsSource       = Enum.GetValues(typeof(gatunek));
        }