private static MediaItem CreateMediaItem(string mediaType, JObject mediaItem) { const string unknownMediaTypeMessage = "Unknown media type"; MediaItem result = new EmptyMediaItem(string.Empty, 0, 0, DateTime.MinValue); if (mediaItem.IsNotNull()) { String mediaTypeName = mediaType ?? "None"; switch (mediaTypeName.ToUpperInvariant()) { case "FLICKRIMAGE": result = new FlickrMediaItem(mediaItem); break; case "YOUTUBEVIDEO": result = new YouTubeMediaItem(mediaItem); break; case "NONE": result = new EmptyMediaItem(mediaItem); break; default: throw new InvalidOperationException(unknownMediaTypeMessage); } } return(result); }
internal static MediaItem CreateMediaItem(String mediaType, YamlMediaItem mediaItem) { const string flickrListUrlKey = "FlickrListUrl"; MediaItem result = null; string title = mediaItem.ItemTitle; int displayWidth = mediaItem.DisplayWidth; int displayHeight = mediaItem.DisplayHeight; DateTime createDate = mediaItem.CreateDate.DateTime; string itemUrl = mediaItem.ItemUrl; String mediaTypeName = mediaType ?? "None"; switch (mediaTypeName.ToUpperInvariant()) { case "FLICKRIMAGE": var flickrListUrl = mediaItem.ExtendedProperties.SingleOrDefault(p => p.Key == flickrListUrlKey)?.Value; result = new FlickrMediaItem(title, displayWidth, displayHeight, createDate, flickrListUrl, itemUrl); break; case "YOUTUBEVIDEO": result = new YouTubeMediaItem(title, displayWidth, displayHeight, createDate, itemUrl); break; case "NONE": result = new EmptyMediaItem(title, displayWidth, displayHeight, createDate); break; default: string message = $"Unknown media type '{mediaTypeName}'"; throw new InvalidOperationException(message); } return(result); }
public MediaPostBuilder AddYouTubeVideo(YouTubeMediaItem video) { base.MediaItem = JObject.FromObject(video); base.MediaType = "YouTubeVideo"; return(this); }