예제 #1
0
        /// <summary>
        ///  Helper method to deserialize a batch serailized via the default serialization
        /// </summary>
        /// <returns>The deserialized batch</returns>
        public static Batch Deserialize(XmlReader xmlReader)
        {
            if (xmlReader.GoToElement())
            {
                Batch result = new Batch();
                LogBase.DeserializeData(xmlReader, result);

                xmlReader.ReadStartElement();

                List <Log> logs = new List <Log>();
                while (xmlReader.GoToSibling())
                {
                    switch (xmlReader.LocalName)
                    {
                    case Log.LogNodeName:
                        var log = Log.Deserialize(xmlReader);
                        logs.Add(log);
                        break;

                    default:
                        xmlReader.Skip();
                        break;
                    }
                }
                result.Logs = logs;
                xmlReader.ReadEndElement();
                return(result);
            }
            else
            {
                throw new Exception("Batch is empty");
            }
        }
예제 #2
0
        /// <summary>
        /// Deserializes a log from Xml. The type of log created will always be Log. To cast after the fact, call CreateLog or CastLog.
        /// </summary>
        public static Log Deserialize(XmlReader xmlReader)
        {
            Log result = new Log(new Dictionary <string, string>());

            if (!LogBase.DeserializeData(xmlReader, result))
            {
                throw new Exception("Log is empty");
            }
            return(result);
        }