Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
        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);
                }
            });
        }
Esempio n. 3
0
        public void SerializeObject(JsonWriter writer, object instance, IJsonSerializeOperationInfo info)
        {
            if (instance == null)
            {
                writer.WriteNull();
            }
            else
            {
                if (_encrypt)
                {
                    var toggler = new EncryptWritesToggler(writer);
                    toggler.Toggle();

                    writer.WriteValue((bool)instance);

                    toggler.Revert();
                }
                else
                {
                    writer.WriteValue((bool)instance);
                }
            }
        }