Beispiel #1
0
        private static Attachment TransformAttachment(VkNet.Model.Attachments.Attachment attachment)
        {
            Attachment a = new Attachment();

            a.Type     = Types[attachment.Type];
            a.FileName = GetUri(attachment).OriginalString;
            return(a);
        }
Beispiel #2
0
        private static Uri GetUri(VkNet.Model.Attachments.Attachment attachment)
        {
            switch (Types[attachment.Type])
            {
            case AttachmentsType.Image:
                return(GetUri((Photo)attachment.Instance));

            case AttachmentsType.Sticker:
                return(GetUri((Sticker)attachment.Instance));
            }
            throw new ZeigHeil();
        }
Beispiel #3
0
        internal static Attachment FromJson(VkResponse response)
        {
            // TODO: Complete it later
            var attachment = new Attachment();

            string type = response["type"];
            switch (type)
            {
                case "photo":
                case "posted_photo":
                    attachment.Type = typeof(Photo);
                    attachment.Photo = response[type];
                    break;

                case "video":
                    attachment.Type = typeof(Video);
                    attachment.Video = response["video"];
                    break;

                case "audio":
                    attachment.Type = typeof(Audio);
                    attachment.Audio = response["audio"];
                    break;

                case "doc":
                    attachment.Type = typeof(Document);
                    attachment.Document = response["doc"];
                    break;

                case "graffiti":
                    attachment.Type = typeof(Graffiti);
                    attachment.Graffiti = response["graffiti"];
                    break;

                case "link":
                    attachment.Type = typeof(Link);
                    attachment.Link = response["link"];
                    break;

                case "note":
                    attachment.Type = typeof(Note);
                    attachment.Note = response["note"];
                    break;

                case "app":
                    attachment.Type = typeof(ApplicationContent);
                    attachment.ApplicationContent = response["app"];
                    break;

                case "poll":
                    attachment.Type = typeof(Poll);
                    attachment.Poll = response["poll"];
                    break;

                case "page":
                    attachment.Type = typeof(Page);
                    attachment.Page = response["page"];
                    break;

                case "album":
                    attachment.Type = typeof(Album);
                    attachment.Album = response["album"];
                    break;

                case "photos_list":
                    attachment.Type = typeof (PhotosList);
                    attachment.PhotosList = response["photos_list"];
                    break;

                case "wall":
                    attachment.Type = typeof (Wall);
                    attachment.Wall = response["wall"];
                    break;

                case "sticker":
                    attachment.Type = typeof (Sticker);
                    attachment.Sticker = response["sticker"];
                    break;

                case "gift":
                    attachment.Type = typeof(Gift);
                    attachment.Gift = response["gift"];
                    break;

                case "wall_reply":
                    attachment.Type = typeof(WallReply);
                    attachment.WallReply = response["wall_reply"];
                    break;

                default:
                    throw new InvalidParameterException(string.Format("The type '{0}' of attachment is not defined. {1}", type, response["date"]));
            }

            return attachment;
        }
Beispiel #4
0
        /// <summary>
        /// Разобрать из json.
        /// </summary>
        /// <param name="response">Ответ сервера.</param>
        /// <returns></returns>
        public static Attachment FromJson(VkResponse response)
        {
            var attachment = new Attachment();

            string type = response["type"];

            switch (type)
            {
            case "photo":
            case "posted_photo":
            {
                attachment.Type  = typeof(Photo);
                attachment.Photo = response[type];
                break;
            }

            case "video":
            {
                attachment.Type  = typeof(Video);
                attachment.Video = response["video"];
                break;
            }

            case "audio":
            {
                attachment.Type  = typeof(Audio);
                attachment.Audio = response["audio"];
                break;
            }

            case "doc":
            {
                attachment.Type     = typeof(Document);
                attachment.Document = response["doc"];
                break;
            }

            case "graffiti":
            {
                attachment.Type     = typeof(Graffiti);
                attachment.Graffiti = response["graffiti"];
                break;
            }

            case "link":
            {
                attachment.Type = typeof(Link);
                attachment.Link = response["link"];
                break;
            }

            case "note":
            {
                attachment.Type = typeof(Note);
                attachment.Note = response["note"];
                break;
            }

            case "app":
            {
                attachment.Type = typeof(ApplicationContent);
                attachment.ApplicationContent = response["app"];
                break;
            }

            case "poll":
            {
                attachment.Type = typeof(Poll);
                attachment.Poll = response["poll"];
                break;
            }

            case "page":
            {
                attachment.Type = typeof(Page);
                attachment.Page = response["page"];
                break;
            }

            case "album":
            {
                attachment.Type  = typeof(Album);
                attachment.Album = response["album"];
                break;
            }

            case "wall":
            {
                attachment.Type = typeof(Post);
                attachment.Wall = response["wall"];
                break;
            }

            case "sticker":
            {
                attachment.Type    = typeof(Sticker);
                attachment.Sticker = response["sticker"];
                break;
            }

            case "gift":
            {
                attachment.Type = typeof(Gift);
                attachment.Gift = response["gift"];
                break;
            }

            case "wall_reply":
            {
                attachment.Type      = typeof(WallReply);
                attachment.WallReply = response["wall_reply"];
                break;
            }

            case "market_album":
            {
                attachment.Type        = typeof(MarketAlbum);
                attachment.MarketAlbum = response["market_album"];
                break;
            }

            case "market":
            {
                attachment.Type   = typeof(Market);
                attachment.Market = response["market"];
                break;
            }

            default:
            {
                throw new InvalidParameterException(string.Format("The type '{0}' of attachment is not defined. {1}", type, response["date"]));
            }
            }

            return(attachment);
        }
Beispiel #5
0
        internal static Attachment FromJson(VkResponse response)
        {
            // TODO: Complete it later
            var attachment = new Attachment();

            string type = response["type"];
            switch (type)
            {
                case "photo":
                case "posted_photo":
                    attachment.Type = typeof(Photo);
                    attachment.Photo = response[type];
                    break;

                case "video":
                    attachment.Type = typeof(Video);
                    attachment.Video = response["video"];
                    break;

                case "audio":
                    attachment.Type = typeof(Audio);
                    attachment.Audio = response["audio"];
                    break;

                case "doc":
                    attachment.Type = typeof(Document);
                    attachment.Document = response["doc"];
                    break;

                case "graffiti":
                    attachment.Type = typeof(Graffiti);
                    attachment.Graffiti = response["graffiti"];
                    break;

                case "link":
                    attachment.Type = typeof(Link);
                    attachment.Link = response["link"];
                    break;

                case "note":
                    attachment.Type = typeof(Note);
                    attachment.Note = response["note"];
                    break;

                case "app":
                    attachment.Type = typeof(ApplicationContent);
                    attachment.ApplicationContent = response["app"];
                    break;

                case "poll":
                    attachment.Type = typeof(Poll);
                    attachment.Poll = response["poll"];
                    break;

                case "page":
                    attachment.Type = typeof(Page);
                    attachment.Page = response["page"];
                    break;

                case "album":
                    attachment.Type = typeof(Album);
                    attachment.Album = response["album"];
                    break;

                default:
                    throw new InvalidParameterException("The type of attachment is not defined.");
            }

            return attachment;
        }