internal void WriteKDL(StreamWriter writer, int depth, PrintConfig printConfig) /*throws IOException*/ { if (Nodes.Count == 0 && depth == 0) { writer.Write(printConfig.NewLine); return; } foreach (var node in Nodes) { for (int i = 0; i < printConfig.Indent * depth; i++) { writer.Write(printConfig.IndentChar); } node.WriteKDLPretty(writer, depth, printConfig); if (printConfig.RequireSemicolons) { writer.Write(';'); } writer.Write(printConfig.NewLine); } }
public void WriteKDL(StreamWriter writer, PrintConfig printConfig) { WriteKDLPretty(writer, printConfig); }
public void WriteKDLPretty(StreamWriter writer, PrintConfig printConfig) // throws IOException { WriteKDL(writer, 0, printConfig); }
public void WriteKDL(StreamWriter writer, PrintConfig printConfig) => PrintUtil.WriteStringQuotedAppropriately(writer, Value, false, printConfig);
public void WriteKDL(StreamWriter writer, PrintConfig printConfig) => writer.Write(Value ? "true" : "false");
public void WriteKDL(StreamWriter writer, PrintConfig printConfig) => writer.Write(Value.ToString());
public void WriteKDL(StreamWriter writer, PrintConfig printConfig) => writer.Write("null");
public static void WriteStringQuotedAppropriately( StreamWriter writer, string str, bool bareAllowed, PrintConfig printConfig) { if (str.Length == 0) { writer.Write("\"\""); return; } int hashDepth = 0; if (!printConfig.EscapeNonPrintableAscii) { int quoteAt = str.IndexOf('"'); while (quoteAt >= 0) { int hashesNeeded = 1; for (int i = quoteAt + 1; i < str.Length && str[i] == '#'; i++) { hashesNeeded++; } hashDepth = Math.Max(hashDepth, hashesNeeded); quoteAt = str.IndexOf('"', quoteAt + 1); } } if (hashDepth == 0 && !str.Contains("\\") && !str.Contains("\"")) { if (bareAllowed && ValidBareId.IsMatch(str)) { writer.Write(str); } else { writer.Write('"'); for (int i = 0; i < str.Length; i++) { char c = str[i]; if (IsPrintableAscii(c)) { writer.Write(c); } else if (c == '\n' && printConfig.EscapeNewLines) { writer.Write("\\n"); } else if (printConfig.EscapeNonPrintableAscii) { writer.Write(GetEscapeIncludingUnicode(c)); } else if (printConfig.EscapeCommon) { writer.Write(GetCommonEscape(c) ?? c.ToString()); } else { writer.Write(c); } } writer.Write('"'); } } else { writer.Write('r'); for (int i = 0; i < hashDepth; i++) { writer.Write('#'); } writer.Write('"'); writer.Write(str); writer.Write('"'); for (int i = 0; i < hashDepth; i++) { writer.Write('#'); } } }