Example #1
0
        private void load()
        {
            string     signature = null;
            string     high      = null;
            string     low       = null;
            string     ext       = null;
            string     lb        = null;
            TextReader tr        = null;

            try
            {
                tr = new StreamReader(fileLocation);

                using (XmlReader reader = XmlReader.Create(tr))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            string name = reader.Name;

                            if (name == "mcu")
                            {
                                signature = reader.GetAttribute("signature");
                            }

                            reader.Read();
                            switch (name)
                            {
                            case "high":
                                high = reader.ReadContentAsString();
                                break;

                            case "low":
                                low = reader.ReadContentAsString();
                                break;

                            case "ext":
                                ext = reader.ReadContentAsString();
                                break;

                            case "lock":
                                lb = reader.ReadContentAsString();
                                break;

                            default:
                                break;
                            }
                        }
                        else if (reader.NodeType == XmlNodeType.EndElement)
                        {
                            if (reader.Name == "mcu" && signature != null)
                            {
                                if (lb != null)
                                {
                                    lockbits.Add(signature, lb);
                                }
                                if (low != null)
                                {
                                    fusebitslo.Add(signature, low);
                                }
                                if (high != null)
                                {
                                    fusebitshi.Add(signature, high);
                                }
                                if (ext != null)
                                {
                                    fusebitsext.Add(signature, ext);
                                }

                                signature = null;
                                high      = null;
                                low       = null;
                                ext       = null;
                                lb        = null;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MsgBox.error("_ERRORLOADFUSES", ex.Message);
            }

            if (tr != null)
            {
                tr.Close();
            }
        }