public ValueSerializer(IObjectGraphTraversalStrategy traversalStrategy, IEventEmitter eventEmitter, IEnumerable <IYamlTypeConverter> typeConverters, LazyComponentRegistrationList <IEnumerable <IYamlTypeConverter>, IObjectGraphVisitor <Nothing> > preProcessingPhaseObjectGraphVisitorFactories, LazyComponentRegistrationList <EmissionPhaseObjectGraphVisitorArgs, IObjectGraphVisitor <IEmitter> > emissionPhaseObjectGraphVisitorFactories) { this.traversalStrategy = traversalStrategy; this.eventEmitter = eventEmitter; this.typeConverters = typeConverters; this.preProcessingPhaseObjectGraphVisitorFactories = preProcessingPhaseObjectGraphVisitorFactories; this.emissionPhaseObjectGraphVisitorFactories = emissionPhaseObjectGraphVisitorFactories; }
public IValueSerializer BuildValueSerializer() { IEnumerable <IYamlTypeConverter> enumerable = BuildTypeConverters(); ITypeInspector arg = BuildTypeInspector(); IObjectGraphTraversalStrategy traversalStrategy = objectGraphTraversalStrategyFactory(arg, typeResolver, enumerable); IEventEmitter eventEmitter = eventEmitterFactories.BuildComponentChain(new WriterEventEmitter()); return(new ValueSerializer(traversalStrategy, eventEmitter, enumerable, preProcessingPhaseObjectGraphVisitorFactories.Clone(), emissionPhaseObjectGraphVisitorFactories.Clone())); }
private void EmitDocument(Emitter emitter, IObjectGraphTraversalStrategy traversalStrategy, IObjectGraphVisitor emittingVisitor, object graph, Type type) { emitter.Emit(new StreamStart()); emitter.Emit(new DocumentStart()); traversalStrategy.Traverse(graph, type, emittingVisitor); emitter.Emit(new DocumentEnd(true)); emitter.Emit(new StreamEnd()); }
public CustomSerializationObjectGraphVisitor(IEmitter emitter, IObjectGraphVisitor nextVisitor, IEnumerable <IYamlTypeConverter> typeConverters, IObjectGraphTraversalStrategy traversalStrategy) : base(nextVisitor) { this.emitter = emitter; this.nextVisitor = nextVisitor; this.traversalStrategy = traversalStrategy; this.typeConverters = typeConverters != null ? typeConverters.ToList() : Enumerable.Empty <IYamlTypeConverter>(); }
private void EmitDocument(IEmitter emitter, IObjectDescriptor graph) { IObjectGraphTraversalStrategy traversalStrategy = this.CreateTraversalStrategy(); IObjectGraphVisitor visitor = this.CreateEmittingVisitor(emitter, traversalStrategy, this.CreateEventEmitter(emitter), graph); emitter.Emit(new StreamStart()); emitter.Emit(new DocumentStart()); traversalStrategy.Traverse(graph, visitor); emitter.Emit(new DocumentEnd(true)); emitter.Emit(new StreamEnd()); }
private IObjectGraphVisitor CreateEmittingVisitor(IEmitter emitter, IObjectGraphTraversalStrategy traversalStrategy, IEventEmitter eventEmitter, IObjectDescriptor graph) { IObjectGraphVisitor nextVisitor = new EmittingObjectGraphVisitor(eventEmitter); nextVisitor = new CustomSerializationObjectGraphVisitor(emitter, nextVisitor, this.Converters); if (!this.IsOptionSet(SerializationOptions.DisableAliases)) { AnchorAssigner visitor = new AnchorAssigner(); traversalStrategy.Traverse(graph, visitor); nextVisitor = new AnchorAssigningObjectGraphVisitor(nextVisitor, eventEmitter, visitor); } if (!this.IsOptionSet(SerializationOptions.EmitDefaults)) { nextVisitor = new DefaultExclusiveObjectGraphVisitor(nextVisitor); } return(nextVisitor); }
private IObjectGraphVisitor CreateEmittingVisitor(IEmitter emitter, IObjectGraphTraversalStrategy traversalStrategy, IEventEmitter eventEmitter, IObjectDescriptor graph) { IObjectGraphVisitor emittingVisitor = new EmittingObjectGraphVisitor(eventEmitter); emittingVisitor = new CustomSerializationObjectGraphVisitor(emitter, emittingVisitor, Converters); if (!IsOptionSet(SerializationOptions.DisableAliases)) { var anchorAssigner = new AnchorAssigner(); traversalStrategy.Traverse(graph, anchorAssigner); emittingVisitor = new AnchorAssigningObjectGraphVisitor(emittingVisitor, eventEmitter, anchorAssigner); } if (!IsOptionSet(SerializationOptions.EmitDefaults)) { emittingVisitor = new DefaultExclusiveObjectGraphVisitor(emittingVisitor); } return emittingVisitor; }
private IObjectGraphVisitor CreateEmittingVisitor(IEmitter emitter, IObjectGraphTraversalStrategy traversalStrategy, IEventEmitter eventEmitter, IObjectDescriptor graph) { IObjectGraphVisitor emittingVisitor = new EmittingObjectGraphVisitor(eventEmitter); emittingVisitor = new CustomSerializationObjectGraphVisitor(emitter, emittingVisitor, Converters, traversalStrategy); if (!IsOptionSet(SerializationOptions.DisableAliases)) { var anchorAssigner = new AnchorAssigner(); traversalStrategy.Traverse(graph, anchorAssigner); emittingVisitor = new AnchorAssigningObjectGraphVisitor(emittingVisitor, eventEmitter, anchorAssigner); } if (!IsOptionSet(SerializationOptions.EmitDefaults)) { emittingVisitor = new DefaultExclusiveObjectGraphVisitor(emittingVisitor); } return(emittingVisitor); }
private IObjectGraphVisitor CreateEmittingVisitor(Emitter emitter, IObjectGraphTraversalStrategy traversalStrategy, IEventEmitter eventEmitter, object graph, Type type) { IObjectGraphVisitor emittingVisitor = new EmittingObjectGraphVisitor(eventEmitter); emittingVisitor = new CustomSerializationObjectGraphVisitor(emitter, emittingVisitor, Converters); if ((options & SerializationOptions.DisableAliases) == 0) { var anchorAssigner = new AnchorAssigner(); traversalStrategy.Traverse(graph, type, anchorAssigner); emittingVisitor = new AnchorAssigningObjectGraphVisitor(emittingVisitor, eventEmitter, anchorAssigner); } if ((options & SerializationOptions.EmitDefaults) == 0) { emittingVisitor = new DefaultExclusiveObjectGraphVisitor(emittingVisitor); } return(emittingVisitor); }
public void WriteYaml(IEmitter emitter, IObjectDescriptor value, IObjectGraphTraversalStrategy traversalStrategy, IObjectGraphVisitor visitor) { emitter.Emit(new Scalar(((MissingDefaultCtor)value.Value).Value)); }
private IObjectGraphVisitor<IEmitter> CreateEmittingVisitor(IEmitter emitter, IObjectGraphTraversalStrategy traversalStrategy, IEventEmitter eventEmitter, IObjectDescriptor graph) { IObjectGraphVisitor<IEmitter> emittingVisitor = new EmittingObjectGraphVisitor(eventEmitter); ObjectSerializer nestedObjectSerializer = (v, t) => SerializeValue(emitter, v, t); emittingVisitor = new CustomSerializationObjectGraphVisitor(emittingVisitor, Converters, nestedObjectSerializer); if (!IsOptionSet(SerializationOptions.DisableAliases)) { var anchorAssigner = new AnchorAssigner(Converters); traversalStrategy.Traverse<Nothing>(graph, anchorAssigner, null); emittingVisitor = new AnchorAssigningObjectGraphVisitor(emittingVisitor, eventEmitter, anchorAssigner); } if (!IsOptionSet(SerializationOptions.EmitDefaults)) { emittingVisitor = new DefaultExclusiveObjectGraphVisitor(emittingVisitor); } return emittingVisitor; }
private void EmitDocument(Emitter emitter, IObjectGraphTraversalStrategy traversalStrategy, IObjectGraphVisitor emittingVisitor, object graph, Type type) { emitter.Emit(new StreamStart()); emitter.Emit(new DocumentStart()); traversalStrategy.Traverse(graph, type, emittingVisitor); emitter.Emit(new DocumentEnd(true)); emitter.Emit(new StreamEnd()); }
private IObjectGraphVisitor CreateEmittingVisitor(Emitter emitter, SerializationOptions options, IObjectGraphTraversalStrategy traversalStrategy, IEventEmitter eventEmitter, object graph, Type type) { IObjectGraphVisitor emittingVisitor = new EmittingObjectGraphVisitor(eventEmitter); emittingVisitor = new CustomSerializationObjectGraphVisitor(emitter, emittingVisitor, converters); if ((options & SerializationOptions.DisableAliases) == 0) { var anchorAssigner = new AnchorAssigner(); traversalStrategy.Traverse(graph, type, anchorAssigner); emittingVisitor = new AnchorAssigningObjectGraphVisitor(emittingVisitor, eventEmitter, anchorAssigner); } if ((options & SerializationOptions.EmitDefaults) == 0) { emittingVisitor = new DefaultExclusiveObjectGraphVisitor(emittingVisitor); } return emittingVisitor; }
private IObjectGraphVisitor <IEmitter> CreateEmittingVisitor(IEmitter emitter, IObjectGraphTraversalStrategy traversalStrategy, IEventEmitter eventEmitter, IObjectDescriptor graph) { IObjectGraphVisitor <IEmitter> emittingVisitor = new EmittingObjectGraphVisitor(eventEmitter); ObjectSerializer nestedObjectSerializer = (v, t) => SerializeValue(emitter, v, t); emittingVisitor = new CustomSerializationObjectGraphVisitor(emittingVisitor, Converters, nestedObjectSerializer); if (!IsOptionSet(SerializationOptions.DisableAliases)) { var anchorAssigner = new AnchorAssigner(Converters); traversalStrategy.Traverse <Nothing>(graph, anchorAssigner, null); emittingVisitor = new AnchorAssigningObjectGraphVisitor(emittingVisitor, eventEmitter, anchorAssigner); } if (!IsOptionSet(SerializationOptions.EmitDefaults)) { emittingVisitor = new DefaultExclusiveObjectGraphVisitor(emittingVisitor); } return(emittingVisitor); }
public void WriteYaml(Core.IEmitter emitter, IObjectDescriptor value, IObjectGraphTraversalStrategy traversalStrategy, IObjectGraphVisitor visitor) { var guid = (System.Guid)value.Value; emitter.Emit(new Core.Events.Scalar(null, null, guid.ToString("D"), jsonCompatible ? ScalarStyle.DoubleQuoted : ScalarStyle.Any, true, false)); }