public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var result = new List<IAsset>(); var assets = JArray.Load(reader); foreach (var asset in assets) { if (asset["Kind"] != null && (string)asset["Kind"] == "VideoResource") { var videoResourceAsset = new VideoResourceAsset(); serializer.Populate(asset.CreateReader(), videoResourceAsset); result.Add(videoResourceAsset); } } return result.ToArray(); }
private Link GetLink(VideoResourceAsset videoResourceAsset) { if (videoResourceAsset.Links == null) { throw new ScraperException("Property 'Links' not found."); } var link = videoResourceAsset.Links.Where(l => l.Target == "Streaming") .OrderByDescending(l => l.Bitrate).FirstOrDefault(); if (link == null) { throw new ScraperException("No element with property 'Target' set to 'Streaming' was found in 'Links' array."); } return(link); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var result = new List <IAsset>(); var assets = JArray.Load(reader); foreach (var asset in assets) { if (asset["Kind"] != null && (string)asset["Kind"] == "VideoResource") { var videoResourceAsset = new VideoResourceAsset(); serializer.Populate(asset.CreateReader(), videoResourceAsset); result.Add(videoResourceAsset); } } return(result.ToArray()); }