Пример #1
0
        private void DeserializeCollection(Collection collection, JObject json)
        {
            DeserializeContainer(collection, json);

            var itemsProp = json.Property("$items");
            if (!itemsProp.HasValues || itemsProp.Value.Type != JTokenType.Object)
                throw new ArgumentException(Strings.JsonProductSerializer.InvalidItems);

            var itemsJson = (JObject)itemsProp.Value;
            foreach (var itemProp in itemsJson.Properties().Where(x =>
                !x.Name.StartsWith("$") && x.HasValues && x.Value.Type == JTokenType.Object))
            {
                var itemJson = (JObject)itemProp.Value;
                var itemSchemaId = GetSchema(itemJson);
                DeserializeElement(collection.CreateItem(itemProp.Name, itemSchemaId), itemJson);
            }
        }