예제 #1
0
        private Attachment getAttachment(XmlNode fromPost)
        {
            if (fromPost != null)
            {
                Attachment attachment     = new Attachment();
                string     attachmentType = fromPost.SelectSingleNode("type").InnerText;
                switch (attachmentType)
                {
                case "app": attachment.Type = AttachmentType.Application; break;

                case "graffiti": attachment.Type = AttachmentType.Graffiti; break;

                case "video": attachment.Type = AttachmentType.Video; break;

                case "audio": attachment.Type = AttachmentType.Audio; break;

                case "photo": attachment.Type = AttachmentType.Photo; break;

                case "posted_photo": attachment.Type = AttachmentType.PostedPhoto; break;

                case "note": attachment.Type = AttachmentType.Note; break;

                case "poll": attachment.Type = AttachmentType.Poll; break;

                case "link": attachment.Type = AttachmentType.Url; break;

                case "checkin": attachment.Type = AttachmentType.Checkin; break;

                case "share": attachment.Type = AttachmentType.Share; break;
                }
                XmlNode attachmentData = fromPost.SelectSingleNode(attachmentType);
                if (attachmentData != null)
                {
                    attachment.Data = AttachmentFactory.GetAttachment(attachment.Type, attachmentData);
                }
                else
                {
                    attachment.Data = null;
                }
                //attachment.ItemId = Convert.ToInt32(fromPost.SelectSingleNode("item_id").InnerText);
                //if (attachment.Type != AttachmentType.Graffiti)
                //{
                //    attachment.OwnerId = Convert.ToInt32(fromPost.SelectSingleNode("owner_id").InnerText);
                //}
                //if (attachment.Type == AttachmentType.Application)
                //{
                //    attachment.ApplicationId = Convert.ToInt32(fromPost.SelectSingleNode("app_id").InnerText);
                //}
                //if (fromPost.SelectSingleNode("thumb_src") != null)
                //{
                //    attachment.ThumbnailUrl = fromPost.SelectSingleNode("thumb_src").InnerText;
                //}
                return(attachment);
            }
            return(null);
        }
예제 #2
0
 private AttachmentData getAttachmentData(AttachmentType type, XmlNode attachmentData)
 {
     return(AttachmentFactory.GetAttachment(type, attachmentData));
 }