Exemple #1
0
        // Internal

        private void LoadFromXmlDocument(XmlNode doc)
        {
            var xe = doc.FirstChild;

            if (xe == null || xe.Name != XmlConstants.RootTag)
            {
                throw new BadXmlException();
            }

            foreach (XmlElement child in xe.ChildNodes)
            {
                var thread = ThreadModel.FromXmlElement(child);
                ThreadsList.Add(thread);
            }

            IsSaved = true;
        }
Exemple #2
0
        // Public

        public static ThreadModel FromXmlElement(XmlElement xe)
        {
            if (xe.Name != XmlConstants.ThreadTag)
            {
                throw new BadXmlException();
            }

            uint id, time;

            try
            {
                id   = Convert.ToUInt32(xe.Attributes[XmlConstants.ThreadIdAttribute].Value);
                time = Convert.ToUInt32(xe.Attributes[XmlConstants.TimeAttribute].Value);
            }
            catch (Exception ex)
            {
                if (ex is XmlException || ex is FormatException || ex is OverflowException)
                {
                    throw new BadXmlException();
                }

                throw;
            }

            var result = new ThreadModel()
            {
                Id   = id,
                Time = time
            };

            foreach (XmlElement child in xe.ChildNodes)
            {
                var method = MethodModel.FromXmlElement(child, result);
                result.Methods.Add(method);
            }

            return(result);
        }