public static ImmutableArray <ReaperProjectNode> ParseFromLines(LineSource lines)
        {
            var nodes = new List <ReaperProjectNode>();

            while (!lines.IsFinished())
            {
                var line = lines.AdvanceLine().Trim();
                if (line.StartsWith("<"))
                {
                    var header      = line.Substring(1);
                    var subelements = ParseFromLines(lines);
                    nodes.Add(NodeFactory.CreateAppropriateProjectElementType(header, subelements));
                }
                else if (line.StartsWith(">"))
                {
                    break;
                }
                else
                {
                    nodes.Add(new ProjectLine(line));
                }
            }

            return(nodes.ToImmutableArray());
        }
        public static ProjectElement ParseProjectFromLines(
            LineSource lines)
        {
            var elements = ParseFromLines(lines);

            if (elements.Length != 2)
            {
                throw new ArgumentException();
            }

            var trailingLine = elements[1] as ProjectLine;

            if (trailingLine == null)
            {
                throw new ArgumentException();
            }
            if (trailingLine.Line.Trim().Length != 0)
            {
                throw new ArgumentException();
            }
            return(elements[0] as ProjectElement);
        }