| | | 1 | | using YamlDotNet.Core; |
| | | 2 | | using YamlDotNet.Core.Events; |
| | | 3 | | using YamlDotNet.Serialization; |
| | | 4 | | using YamlDotNet.Serialization.EventEmitters; |
| | | 5 | | |
| | | 6 | | namespace Kestrun.Utilities.Yaml; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// YAML emitter that forces all mappings and sequences to use flow style |
| | | 10 | | /// </summary> |
| | | 11 | | /// <remarks> |
| | | 12 | | /// Constructor |
| | | 13 | | /// </remarks> |
| | | 14 | | /// <param name="next">The next event emitter in the chain</param> |
| | 3 | 15 | | public class FlowStyleAllEmitter(IEventEmitter next) : ChainedEventEmitter(next) |
| | | 16 | | { |
| | | 17 | | /// <summary> |
| | | 18 | | /// Emit a mapping start event with flow style |
| | | 19 | | /// </summary> |
| | | 20 | | /// <param name="eventInfo">The mapping start event information</param> |
| | | 21 | | /// <param name="emitter">The YAML emitter</param> |
| | | 22 | | public override void Emit(MappingStartEventInfo eventInfo, IEmitter emitter) |
| | | 23 | | { |
| | 2 | 24 | | eventInfo.Style = MappingStyle.Flow; |
| | 2 | 25 | | base.Emit(eventInfo, emitter); |
| | 2 | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Emit a sequence start event with flow style |
| | | 30 | | /// </summary> |
| | | 31 | | /// <param name="eventInfo">The sequence start event information</param> |
| | | 32 | | /// <param name="emitter">The YAML emitter</param> |
| | | 33 | | public override void Emit(SequenceStartEventInfo eventInfo, IEmitter emitter) |
| | | 34 | | { |
| | 1 | 35 | | eventInfo.Style = SequenceStyle.Flow; |
| | 1 | 36 | | nextEmitter.Emit(eventInfo, emitter); |
| | 1 | 37 | | } |
| | | 38 | | } |