internal override void Emit(Emitter emitter) { base.Emit(emitter); switch (Style) { case ScalarStyle.Hex: case ScalarStyle.Plain: ToString(emitter); break; case ScalarStyle.SingleQuoted: emitter.Write('\''); ToString(emitter); emitter.Write('\''); break; case ScalarStyle.DoubleQuoted: emitter.Write('"'); ToString(emitter); emitter.Write('"'); break; default: throw new Exception($"Unsupported scalar style {Style}"); } }
private void EndChildren(Emitter emitter) { switch (Style) { case SequenceStyle.Block: if (m_children.Count == 0) { emitter.Write(']'); } emitter.WriteLine(); break; case SequenceStyle.BlockCurve: if (m_children.Count == 0) { emitter.WriteClose('}'); } emitter.WriteLine(); break; case SequenceStyle.Flow: emitter.WriteClose(']'); break; case SequenceStyle.Raw: if (m_children.Count == 0) { emitter.Write(']'); } emitter.WriteLine(); break; } }
private void StartChildren(Emitter emitter) { switch (Style) { case SequenceStyle.Block: if (m_children.Count == 0) { emitter.Write('['); } break; case SequenceStyle.BlockCurve: if (m_children.Count == 0) { emitter.Write('{'); } break; case SequenceStyle.Flow: emitter.Write('['); break; case SequenceStyle.Raw: if (m_children.Count == 0) { emitter.Write('['); } break; } }
private void StartChildren(Emitter emitter) { if (Style == MappingStyle.Block) { if (m_children.Count == 0) { emitter.Write('{'); } } else if (Style == MappingStyle.Flow) { emitter.Write('{'); } }
internal void Emit(Emitter emitter, bool isSeparator) { if (isSeparator) { emitter.Write("---").WriteWhitespace(); } Root.Emit(emitter); }
internal Emitter ToString(Emitter emitter) { if (Style == ScalarStyle.Hex) { switch (m_objectType) { case ScalarType.Byte: return(emitter.WriteHex((byte)m_value)); case ScalarType.Int16: return(emitter.WriteHex((short)m_value)); case ScalarType.UInt16: return(emitter.WriteHex((ushort)m_value)); case ScalarType.Int32: return(emitter.WriteHex((int)m_value)); case ScalarType.UInt32: return(emitter.WriteHex((uint)m_value)); case ScalarType.Int64: return(emitter.WriteHex(m_value)); case ScalarType.UInt64: return(emitter.WriteHex(unchecked ((ulong)m_value))); case ScalarType.Single: return(emitter.WriteHex((float)m_double)); case ScalarType.Double: return(emitter.WriteHex(m_double)); case ScalarType.String: return(emitter.Write(m_string)); default: throw new NotImplementedException(m_objectType.ToString()); } } switch (m_objectType) { case ScalarType.UInt64: return(emitter.Write(unchecked ((ulong)m_value))); case ScalarType.Single: return(emitter.Write((float)m_double)); case ScalarType.Double: return(emitter.Write(m_double)); case ScalarType.String: return(emitter.Write(m_string)); default: return(emitter.Write(m_value)); } }
private void StartTransition(Emitter emitter, YAMLNode next) { emitter.Write(':').WriteWhitespace(); if (Style == MappingStyle.Block) { if (next.IsMultiline) { emitter.WriteLine(); } } if (next.IsIndent) { emitter.IncreaseIntent(); } }
private void EndChildren(Emitter emitter) { if (Style == MappingStyle.Block) { if (m_children.Count == 0) { emitter.Write('}'); } emitter.WriteLine(); } else if (Style == MappingStyle.Flow) { emitter.WriteClose('}'); } }
private void StartChild(Emitter emitter, YAMLNode next) { if (Style == SequenceStyle.Block || Style == SequenceStyle.BlockCurve) { emitter.Write('-').WriteWhitespace(); if (next.NodeType == NodeType) { emitter.IncreaseIntent(); } } if (next.IsIndent) { emitter.IncreaseIntent(); } }
private void StartChild(Emitter emitter, YAMLNode next) { if (Style.IsAnyBlock()) { emitter.Write('-').Write(' '); if (next.NodeType == NodeType) { emitter.IncreaseIndent(); } } if (next.IsIndent) { emitter.IncreaseIndent(); } }
private Emitter WriteString(Emitter emitter) { if (Style == ScalarStyle.Plain) { emitter.Write(m_string); } else if (Style == ScalarStyle.SingleQuoted) { emitter.WriteDelayed(); for (int i = 0; i < m_string.Length; i++) { char c = m_string[i]; emitter.WriteRaw(c); if (c == '\'') { emitter.WriteRaw(c); } else if (c == '\n') { emitter.WriteRaw("\n "); } } } else if (Style == ScalarStyle.DoubleQuoted) { emitter.WriteDelayed(); int lineLimit = MaxLineLength; for (int i = 0; i < m_string.Length; i++) { if (i >= lineLimit) { emitter.WriteRaw('\\').WriteRaw('\n'); lineLimit += MaxLineLength; } char c = m_string[i]; switch (c) { case '\n': emitter.WriteRaw('\\').WriteRaw('n'); break; case '\r': emitter.WriteRaw('\\').WriteRaw('r'); break; case '\t': emitter.WriteRaw('\\').WriteRaw('t'); break; case '"': emitter.WriteRaw('\\').WriteRaw('"'); break; default: emitter.WriteRaw(c); break; } } } else { throw new NotSupportedException(Style.ToString()); } return(emitter); }