private void PrintNodeName(Pair pair) { if (_valueNodeExpected.Peek()) { _sb.Append("\t"); _sb.Append(pair.GetType().Name); _sb.Append(" "); _sb.Append(QuoteTypeToChar(pair.NameQuotesType)); PrintNsPrefix(pair); _sb.Append(pair.Name); _sb.Append(QuoteTypeToChar(pair.NameQuotesType)); } else { var mappedPair = pair as IMappedPair; _sb.Append(mappedPair?.NameInterval.Begin.Line.ToString().PadLeft(2, '0') ?? "00"); _sb.Append(":"); _sb.Append(mappedPair?.NameInterval.Begin.Column.ToString().PadLeft(2, '0') ?? "00"); _sb.Append('\t', _indent); _sb.Append("\t"); _sb.Append(pair.GetType().Name); _sb.Append(" "); _sb.Append(QuoteTypeToChar(pair.NameQuotesType)); PrintNsPrefix(pair); _sb.Append(pair.Name); _sb.Append(QuoteTypeToChar(pair.NameQuotesType)); } }
private void PrintNsPrefix(Pair pair) { if (!string.IsNullOrEmpty((pair as INsNode)?.NsPrefix)) { _sb.Append(((INsNode)pair).NsPrefix); _sb.Append("."); } }
private void PrintNodeEnd(Pair pair) { _valueNodeExpected.Pop(); if (pair.Value != null) { _sb.AppendLine(); } else if (pair.PairValue != null) { } else { _indent--; } }
private void PrintNodeStart(Pair pair) { if (pair.Value != null) { _sb.Append(Pair.DelimiterToString(pair.Delimiter)); _sb.Append(" "); _sb.Append(QuoteTypeToChar(pair.ValueQuotesType)); PrintValue(pair); _sb.Append(QuoteTypeToChar(pair.ValueQuotesType)); } else if (pair.PairValue != null) { _sb.Append(":= "); _valueNodeExpected.Push(true); Visit(pair.PairValue); _valueNodeExpected.Pop(); } else { _sb.AppendLine(Pair.DelimiterToString(pair.Delimiter)); _indent++; } _valueNodeExpected.Push(false); }
private void PrintNodeStart(Pair pair) { if (pair.Value != null) { _sb.Append(Pair.AssignmentToString(pair.Assignment)); _sb.Append(" "); _sb.Append(((IMappedPair)pair).ValueQuotesType > 0 ? (char)((IMappedPair)pair).ValueQuotesType : '`'); PrintValue(pair); _sb.Append(((IMappedPair)pair).ValueQuotesType > 0 ? (char)((IMappedPair)pair).ValueQuotesType : '`'); } else if (pair.PairValue != null) { _sb.Append(":= "); _valueNodeExpected.Push(true); Visit(pair.PairValue); _valueNodeExpected.Pop(); } else { _sb.AppendLine(Pair.AssignmentToString(pair.Assignment)); _indent++; } _valueNodeExpected.Push(false); }
private void PrintValue(Pair pair) { _sb.Append(pair.Value.Replace("\r\n", "\n").Replace("\n", "\\n").Replace("\t", "\\t")); }