private static bool TryFormatMediaRssThumbnail(MediaRssThumbnail thumbnailToFormat, out XElement thumbnailElement) { thumbnailElement = default; if (string.IsNullOrEmpty(thumbnailToFormat?.Url)) { return(false); } thumbnailElement = new XElement(_media + "thumbnail", new XAttribute("url", thumbnailToFormat.Url)); if (thumbnailToFormat.Height != null) { thumbnailElement.Add(new XAttribute("height", thumbnailToFormat.Height.Value.ToString(CultureInfo.InvariantCulture))); } if (thumbnailToFormat.Width != null) { thumbnailElement.Add(new XAttribute("width", thumbnailToFormat.Width.Value.ToString(CultureInfo.InvariantCulture))); } if (Rfc2326NptTimeSpanFormatter.TryFormatTimeAsString(thumbnailToFormat.Time, out var timeFormatted)) { thumbnailElement.Add(new XAttribute("time", timeFormatted)); } return(true); }
private static bool TryFormatMediaRssText(MediaRssText textToFormat, out XElement textElement) { textElement = default; if (string.IsNullOrEmpty(textToFormat?.Value)) { return(false); } if (!TryFormatMediaRssTypedText(textToFormat, "text", out textElement)) { return(false); } if (!string.IsNullOrEmpty(textToFormat.Lang)) { textElement.Add(new XAttribute("lang", textToFormat.Lang)); } if (Rfc2326NptTimeSpanFormatter.TryFormatTimeAsString(textToFormat.Start, out var startFormatted)) { textElement.Add(new XAttribute("start", startFormatted)); } if (Rfc2326NptTimeSpanFormatter.TryFormatTimeAsString(textToFormat.End, out var endFormatted)) { textElement.Add(new XAttribute("end", endFormatted)); } return(true); }