Example #1
0
 private string ReadCData(LineReader reader, string end)
 {
     string line;
     var sb = new StringBuilder();
     while ((line = reader.ReadLine()) != null && line.TrimEnd() != end)
     {
         sb.AppendLine(line);
     }
     if (line == null && !string.IsNullOrEmpty(end)) throw new Exception("Missing " + end);
     return sb.Length < 2 ? sb.ToString() : sb.ToString(0, sb.Length - 2);
 }
Example #2
0
 private string ReadConditionalBlock(LineReader reader, out bool isElse)
 {
     isElse = false;
     string line;
     var sb = new StringBuilder();
     while ((line = reader.ReadLine()) != null)
     {
         string k = line.Trim();
         isElse = k == "#else";
         if (k == "#endif" || isElse) break;
         sb.AppendLine(line);
     }
     if (line == null) throw new Exception("Missing #else or #endif");
     return sb.Length < 2 ? sb.ToString() : sb.ToString(0, sb.Length - 2);
 }
Example #3
0
 private string ProcessStream(LineReader reader, ref string line)
 {
     while (_Run && (line = reader.ReadLine()) != null)
     {
         if (line.StartsWith("#"))
         {
             string[] parts = Chop(line, 2, ' ');
             string cmd = parts[0].Substring(1).TrimEnd();
             if (cmd.Contains('`')) cmd = Expand(cmd);
             string path = parts.Length > 1 ? parts[1].Trim() : string.Empty;
             var returnValue = DoCommand(reader, cmd, path);
             if (returnValue != null) return returnValue;
         }
     }
     GC.Collect();
     return null;
 }