internal static void Flush(this MissionContents contents, IDictionary <string, MissionContents> labels, string label)
        {
            if (label == string.Empty || contents.Count == 0)
            {
                return;
            }
            if (!labels.ContainsKey(label))
            {
                labels[label] = new MissionContents();
            }

            labels[label] = labels[label].Concat(contents).ToContents();
            contents.Clear();
        }
        public static MissionText Parse(string fileName, IList <string> lines)
        {
            var contents = new MissionContents();

            if (!lines.Any() || !lines.First().StartsWith(":") || IsTemplate(lines))
            {
                return(new MissionText(fileName));
            }

            var labels = new Dictionary <string, MissionContents>();

            var activeLabel = lines.First(l => l.StartsWith(":"));

            foreach (var line in lines)
            {
                if (Nonlines.Contains(line))
                {
                    continue;
                }
                if (line.StartsWith(":") && line != "")
                {
                    var washedLine = line.Trim().Trim(':');
                    if (washedLine == "")
                    {
                        continue;
                    }

                    contents.Flush(labels, activeLabel);

                    if (line == ":EOF")
                    {
                        break;
                    }

                    labels[washedLine] = new MissionContents();
                    activeLabel        = washedLine;
                }
                else
                {
                    var washedLine = line.Trim().Trim(':');
                    contents.Add(washedLine);
                }
            }

            var missionText = GetMissionTextTypeByLabels(fileName, labels, lines);

            return(missionText);
        }