コード例 #1
0
        public XMLMessageList deserializeXML()
        {
            try
            {
                XmlSerializer deserializer = new XmlSerializer(typeof(XMLMessageList));
                var           path         = System.IO.Path.GetFullPath(Directory.GetCurrentDirectory() + "\\Messages.xml");
                TextReader    reader       = new StreamReader(path);
                object        obj          = deserializer.Deserialize(reader);

                XMLMessageList Data = (XMLMessageList)obj;
                reader.Close();
                return(Data);
            }

            catch (Exception e)
            {
                throw new Exception("No XML file found");
            }
        }
コード例 #2
0
        public MainWindow()
        {
            //create a new Serialization object
            //use the Serialization object's deserialize method to read the data from XML file and add to list in XmlData object
            try
            {
                DataProcessor = new XMLDeserializer();
                XmlData       = DataProcessor.deserializeXML();
                MessageFilter.dict.Remove("EMA");
                InitializeComponent();

                inputHeader.Text = XmlData.messageList[i].Header;
                inputBody.Text   = XmlData.messageList[y].Body;
            }

            catch (Exception t)
            {
                MessageBox.Show(t.Message);
            }
        }