private static bool TryParseMediaRssCategory(XElement categoryElement, out MediaRssCategory parsedCategory) { parsedCategory = default; if (string.IsNullOrWhiteSpace(categoryElement?.Value)) { return(false); } parsedCategory = new MediaRssCategory { Value = categoryElement.Value.Trim(), }; if (TryParseStringAttribute(categoryElement.Attribute("label"), out var parsedLabel)) { parsedCategory.Label = parsedLabel; } if (TryParseStringAttribute(categoryElement.Attribute("scheme"), out var parsedScheme)) { parsedCategory.Scheme = parsedScheme; } return(true); }
private static bool TryFormatMediaRssCategory(MediaRssCategory categoryToFormat, out XElement categoryElement) { categoryElement = default; if (string.IsNullOrEmpty(categoryToFormat?.Value)) { return(false); } categoryElement = new XElement(_media + "category", categoryToFormat.Value); if (!string.IsNullOrEmpty(categoryToFormat.Label)) { categoryElement.Add(new XAttribute("label", categoryToFormat.Label)); } if (!string.IsNullOrEmpty(categoryToFormat.Scheme) && categoryToFormat.Scheme != "http://search.yahoo.com/mrss/category_schema") { categoryElement.Add(new XAttribute("scheme", categoryToFormat.Scheme)); } return(true); }