Exemple #1
0
        public void Read(Boo[] array)
        {
            var jsonData = new JsonArray(array.Select(_elementConverter.Write));
            var result   = _converter.Read(jsonData);

            for (var i = 0; i < array.Length; i++)
            {
                result[i].Should().BeEquivalentTo(array[i]);
            }
        }
Exemple #2
0
        public void Read(int?value)
        {
            var number = value == null
                ? JsonValue.Null
                : JsonValue.Number(value.Value);

            _converter.Read(number).Should().Be(value);
        }
        public TNullable?Read(JsonData jsonData)
        {
            var jsonValue = (JsonValue)jsonData;

            if (jsonValue.Type == JsonDataType.Null)
            {
                return(null);
            }
            return(_valueConverter.Read(jsonData));
        }
Exemple #4
0
        public object?ReadValue(JsonObject source)
        {
            var value = (JsonValue)source[nameof(IEntity.Id)];

            if (value.Type == JsonDataType.Number)
            {
                return(_intConverter.Read(value));
            }

            var alias = _stringConverter.Read(value);

            return(_descriptions.GetOrAddAlias(alias));
        }
Exemple #5
0
        public List <TElement> Read(JsonData jsonData)
        {
            var listData = (JsonArray)jsonData;

            var list = new List <TElement>(listData.Length);

            for (var i = 0; i < listData.Length; i++)
            {
                list.Add(_elementConverter.Read(listData[i]));
            }

            return(list);
        }
Exemple #6
0
        public TElement[] Read(JsonData jsonData)
        {
            if (jsonData.Type == JsonDataType.Null)
            {
                return(null);
            }

            var arrayData = (JsonArray)jsonData;

            var array = new TElement[arrayData.Length];

            for (var i = 0; i < array.Length; i++)
            {
                array[i] = _elementConverter.Read(arrayData[i]);
            }

            return(array);
        }
Exemple #7
0
        public void Read(int value)
        {
            var number = JsonValue.Number(value);

            _converter.Read(number).Should().Be(value);
        }
Exemple #8
0
        public void Read(TimeSpan value)
        {
            var number = JsonValue.TimeSpan(value);

            _converter.Read(number).Should().Be(value);
        }
        public void Read(DateTime value)
        {
            var number = JsonValue.DateTime(value);

            _converter.Read(number).Should().Be(value);
        }
            public override object ReadJson(Newtonsoft.Json.JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer)
            {
                var response = _converter.Read(reader.Value);

                return(response);
            }
Exemple #11
0
        public void Read(Boo value)
        {
            var jsonObject = _converter.Write(value);

            _converter.Read(jsonObject).Should().BeEquivalentTo(value);
        }
Exemple #12
0
        public void Read(string value)
        {
            var str = JsonValue.String(value);

            _converter.Read(str).Should().Be(value);
        }
Exemple #13
0
        public void Read(DependencyLifetime value)
        {
            var number = JsonValue.Number((int)value);

            _converter.Read(number).Should().Be(value);
        }
Exemple #14
0
        public void Read(bool value)
        {
            var number = JsonValue.Boolean(value);

            _converter.Read(number).Should().Be(value);
        }