static MapReduceIndex() { MapReduceConverters = new JsonConverterCollection(Default.Converters) { new IgnoreFieldable() }; MapReduceConverters.Freeze(); }
public void Serialize(JsonWriter jsonWriter, object value, Type objectType) { if (jsonWriter == null) throw new ArgumentNullException("jsonWriter"); if (objectType != null) _rootContract = Serializer._contractResolver.ResolveContract(objectType); _internalConverters = Serializer.Converters; SerializeValue(jsonWriter, value, GetContractSafe(value), null, null, null); }
public void Serialize(JsonWriter jsonWriter, object value, Type objectType) { if (jsonWriter == null) throw new ArgumentNullException("jsonWriter"); _rootContract = (objectType != null) ? Serializer._contractResolver.ResolveContract(objectType) : null; _rootLevel = _serializeStack.Count + 1; _internalConverters = Serializer.Converters; JsonContract contract = GetContractSafe(value); try { if (ShouldWriteReference(value, null, contract, null, null)) { WriteReference(jsonWriter, value); } else { SerializeValue(jsonWriter, value, contract, null, null, null); } } catch (Exception ex) { if (IsErrorHandled(null, contract, null, null, jsonWriter.Path, ex)) { HandleError(jsonWriter, 0); } else { // clear context in case serializer is being used inside a converter // if the converter wraps the error then not clearing the context will cause this error: // "Current error context error is different to requested error." ClearErrorContext(); throw; } } finally { // clear root contract to ensure that if level was > 1 then it won't // accidently be used for non root values _rootContract = null; } }
/// <summary> /// Writes this token to a <see cref="JsonWriter"/>. /// </summary> /// <param name="writer">A <see cref="JsonWriter"/> into which this method will write.</param> /// <param name="converters">A collection of <see cref="JsonConverter"/> which will be used when writing the token.</param> public override void WriteTo(JsonWriter writer, JsonConverterCollection converters) { writer.WriteStartConstructor(_name); foreach (JToken token in Children()) { token.WriteTo(writer, converters); } writer.WriteEndConstructor(); }