Exemplo n.º 1
0
        protected override bool OnArrayPropertyDetected(string propertyName, JsonReader reader)
        {
            if (propertyName == "items" || propertyName == "i")
            {
                Items.ReadJson(reader);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        protected override bool OnObjectItemDetected(JsonReader reader)
        {
            var x         = Activator.CreateInstance <TDataItem>();
            var jsonModel = x as JsonModel;

            if (jsonModel != null)
            {
                jsonModel.ReadJson(reader);
            }
            else
            {
                var emptyReader = new EmptyJson();
                emptyReader.Accumulate = true;
                emptyReader.ReadJson(reader);

                x = (TDataItem)JsonConvert.DeserializeObject(emptyReader.JsonString, typeof(TDataItem));
            }

            items.Add(x);
            return(true);
        }
Exemplo n.º 3
0
        protected override bool OnArrayPropertyDetected(string propertyName, JsonReader reader)
        {
            if (string.Compare(propertyName, "items", StringComparison.OrdinalIgnoreCase) == 0)
            {
                items = new List <TDataItem>();

                if (typeof(TDataItem).IsBasicType())
                {
                    var x = new JsonArrayOfBasicType <TDataItem>();
                    x.ReadJson(reader);

                    foreach (var item in x)
                    {
                        items.Add(item);
                    }

                    return(true);
                }
                else
                {
                    if (typeof(TDataItem).IsJsonModel())
                    {
                        var x = new JsonArrayOfObject <TDataItem>();
                        x.ReadJson(reader);

                        foreach (var item in x)
                        {
                            items.Add(item);
                        }

                        return(true);
                    }
                }
            }
            return(false);
        }