public static void WriteStringValue( this DocumentWriter writer, StringValueNode node) { if (node.Block) { writer.Write("\"\"\""); var lines = node.Value .Replace("\"\"\"", "\\\"\"\"") .Replace("\r", string.Empty) .Split('\n'); foreach (var line in lines) { writer.WriteLine(); writer.WriteIndentation(); writer.Write(line); } writer.WriteLine(); writer.WriteIndentation(); writer.Write("\"\"\""); } else { writer.Write($"\"{WriteEscapeCharacters(node.Value)}\""); } }
public void Indent_WriteIndentation_Unindent_WriteIndentation() { // arrange var stringBuilder = new StringBuilder(); var writer = new DocumentWriter(stringBuilder); // act writer.Indent(); writer.WriteIndentation(); writer.WriteLine(); writer.Unindent(); writer.WriteIndentation(); // assert Assert.Equal( " " + writer.NewLine + string.Empty, stringBuilder.ToString()); }
public void WriteIndentation() { // arrange var stringBuilder = new StringBuilder(); var writer = new DocumentWriter(stringBuilder); // act writer.WriteIndentation(); // assert Assert.Equal(string.Empty, stringBuilder.ToString()); }
protected override void VisitSelectionSet(SelectionSetNode node) { if (node != null && node.Selections.Any()) { _writer.Write('{'); string separator; if (_indent) { _writer.WriteLine(); _writer.Indent(); separator = Environment.NewLine; } else { _writer.WriteSpace(); separator = " "; } WriteMany(node.Selections, VisitSelection, separator); if (_indent) { _writer.WriteLine(); _writer.Unindent(); } else { _writer.WriteSpace(); } _writer.WriteIndentation(); _writer.Write('}'); } }