/// <summary> /// Writes the JSON representation of the object. /// </summary> public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { var serializationMap = GetSerializationMapForType(value.GetType()); UsedSerializationMaps.Add(serializationMap); serializationMap.WriterFactory(writer, value, serializer, evWriter, IsPostback); }
/// <summary> /// Writes the JSON representation of the object. /// </summary> public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { var evSuppressLevel = evWriter.Value.SuppressedLevel; try { var serializationMap = GetSerializationMapForType(value.GetType()); UsedSerializationMaps.Add(serializationMap); serializationMap.WriterFactory(writer, value, serializer, evWriter.Value, IsPostback); } finally { // safety check: we are not leaking suppressed reader accidentally if (evSuppressLevel != evWriter.Value.SuppressedLevel) { // Newtonsoft.Json may catch and consume the exception - kill the writer to be sure that serialization can not continue writer.Close(); throw new SecurityException("encrypted values state corrupted."); } } }