public static Build Read(string filePath)
 {
     if (filePath.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
     {
         return(XmlLogReader.ReadFromXml(filePath));
     }
     else
     {
         return(BinaryLogReader.Read(filePath));
     }
 }
예제 #2
0
        public static Build Read(string filePath)
        {
            if (filePath.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
            {
                return(XmlLogReader.ReadFromXml(filePath));
            }
            else if (filePath.EndsWith(".binlog", StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    return(BinaryLog.ReadBuild(filePath));
                }
                catch (Exception)
                {
                    if (DetectLogFormat(filePath) == ".buildlog")
                    {
                        return(BinaryLogReader.Read(filePath));
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            else if (filePath.EndsWith(".buildlog", StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    return(BinaryLogReader.Read(filePath));
                }
                catch (Exception)
                {
                    if (DetectLogFormat(filePath) == ".binlog")
                    {
                        return(BinaryLog.ReadBuild(filePath));
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            return(null);
        }
예제 #3
0
        public static Build ReadFromXml(string xmlFilePath, Action <string> statusUpdate = null)
        {
            Build build = null;

            try
            {
                if (statusUpdate != null)
                {
                    statusUpdate("Loading " + xmlFilePath);
                }

                var doc  = XDocument.Load(xmlFilePath, LoadOptions.PreserveWhitespace);
                var root = doc.Root;

                if (statusUpdate != null)
                {
                    statusUpdate("Populating tree");
                }

                var reader = new XmlLogReader();
                build = (Build)reader.ReadNode(root);
            }
            catch (Exception ex)
            {
                build = new Build()
                {
                    Succeeded = false
                };
                build.AddChild(new Error()
                {
                    Text = "Error when opening file: " + xmlFilePath
                });
                build.AddChild(new Error()
                {
                    Text = ex.ToString()
                });
            }

            return(build);
        }
예제 #4
0
        public static Build ReadFromXml(string xmlFilePath)
        {
            var build = new XmlLogReader().Read(xmlFilePath);

            return(build);
        }
예제 #5
0
 public static Build ReadXmlLog(Stream stream) => XmlLogReader.ReadFromXml(stream);