/// <summary> Write to YAML </summary> protected internal override void Write(WriteStream stream) { if (Content) { stream.Append("y"); } else { stream.Append("n"); } }
/// <summary> /// Write the base64 content to YAML /// </summary> /// <remarks> The lines are splitted in blocks of 20 bytes </remarks> protected internal override void Write(WriteStream stream) { stream.Append("!!binary |" + "\n"); string bin = System.Convert.ToBase64String(content); while (bin.Length > 75) { stream.Append(" " + bin.Substring(0, 75) + "\n"); bin = bin.Substring(75); } stream.Append(" " + bin); // Old coden, everything on one line // stream.Append ("!!binary \"" + System.Convert.ToBase64String (content) + "\""); }
/// <summary> Write to YAML </summary> protected internal override void Write(WriteStream stream) { foreach (MappingNode node in childNodes) { stream.Append("? "); stream.Indent(); Yaml.Net.Node key = node.Key; key.Write(stream); stream.UnIndent(); stream.Append(": "); stream.Indent(); node.Value.Write(stream); stream.UnIndent(); } }
/// <summary> Write back to a stream </summary> protected internal override void Write(WriteStream stream) { foreach (Node node in childNodes) { stream.Append("- "); stream.Indent(); node.Write(stream); stream.UnIndent(); } }
/// <summary> Write to a YAML node </summary> protected internal override void Write(WriteStream stream) { if (content.Equals(double.NaN)) { stream.Append("!!float .NaN"); } else if (content.Equals(double.NegativeInfinity)) { stream.Append("!!float -.Inf"); } else if (content.Equals(double.PositiveInfinity)) { stream.Append("!!float +.Inf"); } else { stream.Append("!!float " + content); } }
/// <summary> Write </summary> protected internal override void Write(WriteStream stream) { // TODO, not required, but writing to block or folded scalars // generates a little more neat code. // Analyze string bool multiline = false; bool mustbequoted = false; for (int i = 0; i < content.Length; i++) { char c = content[i]; if (c == '\n') multiline = true; // We quote everything except strings like /[a-zA-Z]*/ // However there are more strings which don't require // quotes. if (!(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')) mustbequoted = true; } // Double quoted strings if (mustbequoted) { stream.Append("\""); for (int i = 0; i < content.Length; i++) { char c = content[i]; // Backslash if (c == '\\') stream.Append("\\" + "\\"); // Double quote else if (c == '\"') stream.Append("\\" + "\""); // Single quote else if (c == '\'') stream.Append("\\" + "\'"); // ASCII null else if (c == '\0') stream.Append("\\0"); // ASCII bell else if (c == (char)0x7) stream.Append("\\a"); // ASCII backspace else if (c == (char)0x8) stream.Append("\\b"); // ASCII horizontal tab else if (c == (char)0x9) stream.Append("\\t"); // ASCII newline else if (c == (char)0xA) stream.Append("\\n"); // ASCII vertical tab else if (c == (char)0xB) stream.Append("\\v"); // ASCII form feed else if (c == (char)0xC) stream.Append("\\f"); // ASCII carriage return else if (c == (char)0xD) stream.Append("\\r"); // ASCII escape else if (c == (char)0x1D) stream.Append("\\e"); // Unicode next line else if (c == (char)0x85) stream.Append("\\N"); // Unicode non breaking space else if (c == (char)0xA0) stream.Append("\\_"); // TODO larger unicode characters else stream.Append("" + c); } stream.Append("\""); } // Simple non-quoted strings else stream.Append(content); }
/// <summary> Write to YAML </summary> protected internal override void Write(WriteStream stream) { stream.Append(content.ToString()); }
/// <summary> Write to YAML </summary> protected internal override void Write(WriteStream stream) { stream.Append("~"); }
/// <summary> Write </summary> protected internal override void Write(WriteStream stream) { // TODO, not required, but writing to block or folded scalars // generates a little more neat code. // Analyze string bool multiline = false; bool mustbequoted = false; for (int i = 0; i < content.Length; i++) { char c = content[i]; if (c == '\n') { multiline = true; } // We quote everything except strings like /[a-zA-Z]*/ // However there are more strings which don't require // quotes. if (!(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')) { mustbequoted = true; } } // Double quoted strings if (mustbequoted) { stream.Append("\""); for (int i = 0; i < content.Length; i++) { char c = content[i]; // Backslash if (c == '\\') { stream.Append("\\" + "\\"); } // Double quote else if (c == '\"') { stream.Append("\\" + "\""); } // Single quote else if (c == '\'') { stream.Append("\\" + "\'"); } // ASCII null else if (c == '\0') { stream.Append("\\0"); } // ASCII bell else if (c == (char)0x7) { stream.Append("\\a"); } // ASCII backspace else if (c == (char)0x8) { stream.Append("\\b"); } // ASCII horizontal tab else if (c == (char)0x9) { stream.Append("\\t"); } // ASCII newline else if (c == (char)0xA) { stream.Append("\\n"); } // ASCII vertical tab else if (c == (char)0xB) { stream.Append("\\v"); } // ASCII form feed else if (c == (char)0xC) { stream.Append("\\f"); } // ASCII carriage return else if (c == (char)0xD) { stream.Append("\\r"); } // ASCII escape else if (c == (char)0x1D) { stream.Append("\\e"); } // Unicode next line else if (c == (char)0x85) { stream.Append("\\N"); } // Unicode non breaking space else if (c == (char)0xA0) { stream.Append("\\_"); } // TODO larger unicode characters else { stream.Append("" + c); } } stream.Append("\""); } // Simple non-quoted strings else { stream.Append(content); } }
/// <summary> Write to YAML </summary> protected internal override void Write(WriteStream stream) { stream.Append(YamlString()); }
/// <summary> Write to a YAML node </summary> protected internal override void Write(WriteStream stream) { if (content.Equals(double.NaN)) stream.Append("!!float .NaN"); else if (content.Equals(double.NegativeInfinity)) stream.Append("!!float -.Inf"); else if (content.Equals(double.PositiveInfinity)) stream.Append("!!float +.Inf"); else stream.Append("!!float " + content); }
/// <summary> Write to YAML </summary> protected internal override void Write(WriteStream stream) { if (Content) stream.Append("y"); else stream.Append("n"); }