public new static VkLinkAttachment FromJson(JToken json) { if (json == null) { throw new ArgumentException("Json can not be null."); } var result = new VkLinkAttachment(); if (json["url"] != null) { result.Url = (string)json["url"]; } if (json["title"] != null) { result.Title = (string)json["title"]; } if (json["description"] != null) { result.Description = (string)json["description"]; } return(result); }
public static List <VkAttachment> FromJson(JToken json) { var result = new List <VkAttachment>(); foreach (var a in json) { switch (a["type"].Value <string>()) { case "audio": result.Add(VkAudioAttachment.FromJson(a["audio"])); break; case "photo": result.Add(VkPhotoAttachment.FromJson(a["photo"])); break; case "sticker": result.Add(VkStickerAttachment.FromJson(a["sticker"])); break; case "gift": result.Add(VkGiftAttachment.FromJson(a["gift"])); break; case "link": result.Add(VkLinkAttachment.FromJson(a["link"])); break; case "doc": result.Add(VkDocumentAttachment.FromJson(a["doc"])); break; case "video": result.Add(VkVideoAttachment.FromJson(a["video"])); break; case "wall": result.Add(VkWallPostAttachment.FromJson(a["wall"])); break; } } return(result); }