private static bool TryFormatMediaRssScene(MediaRssScene sceneToFormat, out XElement sceneElement) { sceneElement = default; if (sceneToFormat == null) { return(false); } if (!string.IsNullOrEmpty(sceneToFormat.Title)) { // ReSharper disable once ConstantNullCoalescingCondition sceneElement = sceneElement ?? new XElement(_media + "scene"); sceneElement.Add(new XElement("sceneTitle", sceneToFormat.Title)); } if (!string.IsNullOrEmpty(sceneToFormat.Description)) { sceneElement = sceneElement ?? new XElement(_media + "scene"); sceneElement.Add(new XElement("sceneDescription", sceneToFormat.Description)); } if (MinutesSecondsTimeSpanFormatter.TryFormatTimeAsString(sceneToFormat.StartTime, out var startTimeFormatted)) { sceneElement = sceneElement ?? new XElement(_media + "scene"); sceneElement.Add(new XElement("sceneStartTime", startTimeFormatted)); } if (MinutesSecondsTimeSpanFormatter.TryFormatTimeAsString(sceneToFormat.EndTime, out var endTimeFormatted)) { sceneElement = sceneElement ?? new XElement(_media + "scene"); sceneElement.Add(new XElement("sceneEndTime", endTimeFormatted)); } if (sceneElement == null) { return(false); } return(true); }
private static bool TryFormatMediaRssLocation(MediaRssLocation locationToFormat, XNamespaceAliasSet namespaceAliases, ExtensionManifestDirectory extensionManifestDirectory, out XElement locationElement) { locationElement = default; if (locationToFormat == null) { return(false); } var childObjects = new List <object>(); if (MinutesSecondsTimeSpanFormatter.TryFormatTimeAsString(locationToFormat.Start, out var startFormatted)) { childObjects.Add(new XAttribute("start", startFormatted)); } if (MinutesSecondsTimeSpanFormatter.TryFormatTimeAsString(locationToFormat.End, out var endFormatted)) { childObjects.Add(new XAttribute("end", endFormatted)); } if (!string.IsNullOrEmpty(locationToFormat.Description)) { childObjects.Add(new XAttribute("description", locationToFormat.Description)); } // extensions if (ExtensibleEntityFormatter.TryFormatXElementExtensions(locationToFormat, namespaceAliases, extensionManifestDirectory, out var extensionElements)) { childObjects.AddRange(extensionElements); } if (!childObjects.Any()) { return(false); } locationElement = new XElement(_media + "location", childObjects); return(true); }