public void SerializeValue(IEmitter emitter, object value, Type type) { var actualType = type != null ? type : value != null?value.GetType() : typeof(object); var staticType = type ?? typeof(object); var graph = new ObjectDescriptor(value, actualType, staticType); var preProcessingPhaseObjectGraphVisitors = preProcessingPhaseObjectGraphVisitorFactories.BuildComponentList(typeConverters); foreach (var visitor in preProcessingPhaseObjectGraphVisitors) { traversalStrategy.Traverse(graph, visitor, null); } ObjectSerializer nestedObjectSerializer = (v, t) => SerializeValue(emitter, v, t); var emittingVisitor = emissionPhaseObjectGraphVisitorFactories.BuildComponentChain( new EmittingObjectGraphVisitor(eventEmitter), inner => new EmissionPhaseObjectGraphVisitorArgs(inner, eventEmitter, preProcessingPhaseObjectGraphVisitors, typeConverters, nestedObjectSerializer) ); traversalStrategy.Traverse(graph, emittingVisitor, emitter); }