Пример #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;
        }
Пример #2
0
        public void Write(SliceSection section, StringBuilder sb)
        {
            if (section.SectionType == SliceSection.Type.FROM)
            {
                foreach (var line in section.Lines)
                {
                    sb.Append("FROM ").AppendLine(line);
                }
            }

            if (section.SectionType == SliceSection.Type.RUN)
            {
                var text = string.Join($" && {"\\"} {Environment.NewLine}", section.Lines);
                sb.Append("RUN ");
                sb.AppendLine(text);
            }
        }
Пример #3
0
        public void Write(SliceSection section, StringBuilder sb)
        {
            if (section.SectionType == SliceSection.Type.OS)
            {
                foreach (var line in section.Lines)
                {
                    sb.AppendLine("# " + line);
                }
            }

            if (section.SectionType == SliceSection.Type.RUN)
            {
                foreach (var line in section.Lines)
                {
                    sb.AppendLine(line);
                }
            }
        }
Пример #4
0
 public void Write(SliceSection section, StringBuilder sb)
 {
     var text = string.Join($" && {"\\"} {Environment.NewLine}", section.Lines);
     sb.Append("RUN ");
     sb.AppendLine(text);
 }