Пример #1
0
        private MutableDocument([NotNull] MutableDocument other)
            : this((Document)other)
        {
            var dict = new MutableDictionaryObject();

            if (other._dict != null)
            {
                foreach (var item in other._dict)
                {
                    dict.SetValue(item.Key, MutableCopy(item.Value));
                }
            }

            _dict = dict;
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var dict = new MutableDictionaryObject();

            if (reader.TokenType == JsonToken.StartObject)
            {
                reader.Read();
            }

            while (reader.TokenType != JsonToken.EndObject && reader.Read())
            {
                var key = reader.Value as string;
                if (key == null)
                {
                    throw new InvalidDataException("Non-string or null key in data to be deserialized");
                }

                reader.Read();
                var value = reader.Value;
                dict.SetValue(key, value);
            }

            return(dict);
        }
Пример #3
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var dict = new MutableDictionaryObject();

            if (reader.TokenType == JsonToken.StartObject)
            {
                reader.Read();
            }

            while (reader.TokenType != JsonToken.EndObject && reader.Read())
            {
                var key = reader.Value as string;
                if (key == null)
                {
                    throw new InvalidDataException(CouchbaseLiteErrorMessage.InvalidValueToBeDeserialized);
                }

                reader.Read();
                var value = reader.Value;
                dict.SetValue(key, value);
            }

            return(dict);
        }