Inheritance: YamlDotNet.Serialization.ObjectGraphVisitors.ChainedObjectGraphVisitor
Beispiel #1
0
		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;
		}
Beispiel #2
0
            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;
            }