示例#1
0
 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));
     }
 }
示例#2
0
 private void PrintNsPrefix(Pair pair)
 {
     if (!string.IsNullOrEmpty((pair as INsNode)?.NsPrefix))
     {
         _sb.Append(((INsNode)pair).NsPrefix);
         _sb.Append(".");
     }
 }
示例#3
0
        private void PrintNodeEnd(Pair pair)
        {
            _valueNodeExpected.Pop();

            if (pair.Value != null)
            {
                _sb.AppendLine();
            }
            else if (pair.PairValue != null)
            {
            }
            else
            {
                _indent--;
            }
        }
示例#4
0
 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);
 }
示例#5
0
 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);
 }
示例#6
0
 private void PrintValue(Pair pair)
 {
     _sb.Append(pair.Value.Replace("\r\n", "\n").Replace("\n", "\\n").Replace("\t", "\\t"));
 }