Beispiel #1
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);
        }
Beispiel #2
0
        public static List <VkAttachment> FromJson(JToken json, string apiVersion = null)
        {
            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;
                }
            }

            return(result);
        }