コード例 #1
0
        public MsnLog Read(string msnHistoryFile)
        {
            if (string.IsNullOrEmpty(msnHistoryFile))
            {
                throw new ArgumentNullException("The file name can not be null");
            }
            if (File.Exists(msnHistoryFile) == false)
            {
                throw new FileNotFoundException("Can not find file" + msnHistoryFile);
            }

            var log = default(MsnLog);

            var xmlDoc = new XmlDocument();

            using (var xmlReader = new XmlTextReader(msnHistoryFile))
            {
                xmlDoc.Load(xmlReader);

                log = new MsnLog()
                {
                    XmlFilePath = new FileInfo(msnHistoryFile).FullName
                };
                ReadHead(xmlDoc, log);

                var rootNode = ReadLogBasicProperty(xmlDoc, log);

                ReadMessages(log, rootNode);
            }

            return(log);
        }
コード例 #2
0
        private static void ReadMessages(MsnLog log, XmlNode rootNode)
        {
            var messages = rootNode.SelectNodes("*");

            foreach (XmlNode msgNode in messages)
            {
                log.Messages.Add(MsnMessageFactory.Create(msgNode));
            }
        }
コード例 #3
0
        private static XmlNode ReadLogBasicProperty(XmlDocument xmlDoc, MsnLog log)
        {
            var logNode = xmlDoc.SelectSingleNode("Log");

            log.FirstSessionID = int.Parse(logNode.Attributes["FirstSessionID"].Value);
            log.LastSessionID  = int.Parse(logNode.Attributes["LastSessionID"].Value);

            return(logNode);
        }
コード例 #4
0
 private static void ReadHead(XmlDocument xmlDoc, MsnLog log)
 {
     log.Declaration = xmlDoc.FirstChild as XmlDeclaration;
     log.Xsl         = xmlDoc.FirstChild.NextSibling as XmlProcessingInstruction;
 }