public static MediaItemMetadata ParseInMembers(IEnumerable <XElement> members) { MediaItemMetadata meta = new MediaItemMetadata(); meta.width = members.ParseInMember("width", MemberValueTypes.@int).ToInt32(); meta.height = members.ParseInMember("height", MemberValueTypes.@int).ToInt32(); meta.file = members.ParseInMember("file", MemberValueTypes.@string); //sizes List <XElement> sizes = members .Where(x => x.Element("name").Value.Equals("sizes")) .FirstOrDefault() .Element("value").Element("struct").Elements("member").ToList(); List <MediaItemSize> sizeList = new List <MediaItemSize>(); foreach (XElement elem in sizes) { sizeList.Add(MediaItemSize.ParseInMembers(elem.Element("value").Element("struct").Elements("member"))); } meta.sizes = sizeList.ToArray(); //Image Meta Data XElement imageMetaElement = members .Where(x => x.Element("name").Value.Equals("image_meta")) .FirstOrDefault(); meta.imageMeta = PostThumbnailImageMeta.ParseInMembers(imageMetaElement.Element("value").Element("struct").Elements("member")); return(meta); }
public static MediaItem ParseInMembers(IEnumerable <XElement> members) { MediaItem item = new MediaItem(); item.attachment_id = members.ParseInMember("attachment_id", MemberValueTypes.@string); item.parent = members.ParseInMember("parent", MemberValueTypes.@int).ToInt32(); item.link = members.ParseInMember("link", MemberValueTypes.@string); item.title = members.ParseInMember("title", MemberValueTypes.@string); item.caption = members.ParseInMember("caption", MemberValueTypes.@string); item.description = members.ParseInMember("description", MemberValueTypes.@string); item.thumbnail = members.ParseInMember("thumbnail", MemberValueTypes.@string); //metadatas List <XElement> meta = members .Where(x => x.Element("name").Value.Equals("metadata")) .FirstOrDefault() .Element("value") .Element("struct") .Elements("member").ToList(); item.metaData = MediaItemMetadata.ParseInMembers(meta); return(item); }