Beispiel #1
0
        public static SliceSection Parse(IList<string> lines, int lineStart)
        {
            var section = new SliceSection
            {
                Lines = new List<string>()
            };

            for (var pos = lineStart; pos < lines.Count; pos++)
            {
                var line = lines[pos].Trim();
                Type foundType;
                Enum.TryParse(line, out foundType);

                if (foundType != Type.None && section.SectionType == Type.None)
                {
                    section.StartLine = pos;
                    section.SectionType = foundType;
                }
                else if (foundType != Type.None && section.SectionType != Type.None)
                {
                    break;
                }
                else if (section.SectionType != Type.None && line.Length > 0)
                {
                    section.Lines.Add(line);
                    section.EndLine = pos;
                }
            }

            return section.SectionType != Type.None ? section : null;
        }
Beispiel #2
0
        public Slice(string relPath, SemVerInfo info, IList <string> lines)
        {
            RelPath  = relPath;
            Info     = info;
            Sections = new List <SliceSection>();

            int          lineStart = 0;
            SliceSection section;

            while ((section = SliceSection.Parse(lines, lineStart)) != null)
            {
                lineStart = section.EndLine > lineStart ? section.EndLine : lineStart + 1;
                Sections.Add(section);
            }

            foreach (var s in Sections.Where(s => s.SectionType == SliceSection.Type.DEP))
            {
                foreach (var line in s.Lines.Where(l => !l.StartsWith("#")))
                {
                    var depInfo = new SemVerInfo(line);
                    if (!DepInfos.Contains(depInfo))
                    {
                        DepInfos.Add(depInfo);
                    }
                }
            }
        }
Beispiel #3
0
        public static SliceSection Parse(IList <string> lines, int lineStart)
        {
            var section = new SliceSection
            {
                Lines = new List <string>()
            };

            for (var pos = lineStart; pos < lines.Count; pos++)
            {
                var  line = lines[pos].Trim();
                Type foundType;
                Enum.TryParse(line, out foundType);

                if (foundType != Type.None && section.SectionType == Type.None)
                {
                    section.StartLine   = pos;
                    section.SectionType = foundType;
                }
                else if (foundType != Type.None && section.SectionType != Type.None)
                {
                    break;
                }
                else if (section.SectionType != Type.None && line.Length > 0)
                {
                    section.Lines.Add(line);
                    section.EndLine = pos;
                }
            }

            return(section.SectionType != Type.None ? section : null);
        }
Beispiel #4
0
 public void Write(SliceSection section, StringBuilder sb)
 {
     if (section.SectionType == SliceSection.Type.RUN)
     {
         foreach (var line in section.Lines)
         {
             sb.AppendLine(line);
         }
     }
 }
Beispiel #5
0
        public void Write(SliceSection section, StringBuilder sb)
        {
            if (section.SectionType != SliceSection.Type.RUN)
            {
                foreach (var line in section.Lines.Where(item => !item.StartsWith("#")))
                {
                    sb.Append(section.SectionType).Append(" ").AppendLine(line);
                }
            }

            if (section.SectionType == SliceSection.Type.RUN)
            {
                var text = string.Join($" && {"\\"} {Environment.NewLine}", section.Lines.Where(item => !item.StartsWith("#")));
                sb.Append("RUN ");
                sb.AppendLine(text);
            }
        }