示例#1
0
        public static new VkGiftAttachment FromJson(JToken json)
        {
            if (json == null)
            {
                throw new ArgumentException("Json can not be null.");
            }

            var result = new VkGiftAttachment();

            result.Id = (long)json["id"];

            if (json["thumb_256"] != null)
            {
                result.Thumb256 = (string)json["thumb_256"];
            }

            if (json["thumb_96"] != null)
            {
                result.Thumb96 = (string)json["thumb_96"];
            }

            if (json["thumb_48"] != null)
            {
                result.Thumb48 = (string)json["thumb_48"];
            }

            return(result);
        }
示例#2
0
        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);
        }