public void SerializeObject(JsonWriter writer, object instance, IJsonSerializeOperationInfo info) { if (instance == null) { writer.WriteNull(); } else { var serializer = _serializerCache.GetOrAdd(Tuple.Create(instance.GetType(), _encrypt), tuple => GetSerializer(tuple.Item1)); if (_encrypt) { var toggler = new EncryptWritesToggler(writer); toggler.Toggle(); serializer.SerializeObject(writer, instance, info); toggler.Revert(); } else { serializer.SerializeObject(writer, instance, info); } } }
public void SerializeObject(JsonWriter writer, object instance, IJsonSerializeOperationInfo info) { if (instance == null) { writer.WriteNull(); } else { if (_encrypt) { var toggler = new EncryptWritesToggler(writer); toggler.Toggle(); _write(writer, instance); toggler.Revert(); } else { _write(writer, instance); } } }
private Action<JsonWriter, object, IJsonSerializeOperationInfo> GetIDictionaryOfAnythingToAnythingWriteAction() { return (writer, instance, info) => { if (_encrypt) { var toggler = new EncryptWritesToggler(writer); toggler.Toggle(); WriteIDictionaryOfAnythingToAnything(writer, instance, info); toggler.Revert(); } else { WriteIDictionaryOfAnythingToAnything(writer, instance, info); } }; }