private static bool TryParseAtom10Content(XElement contentElement, out Atom10Content parsedContent) { parsedContent = default; if (contentElement == null) { return(false); } parsedContent = new Atom10Content(); parsedContent.Type = contentElement.Attribute("type")?.Value ?? "text"; parsedContent.Src = contentElement.Attribute("src")?.Value; if (!TryParseValueByType(parsedContent.Type, contentElement, out var parsedValue)) { return(false); } parsedContent.Value = parsedValue; parsedContent.Lang = contentElement.Attribute(_xml + "lang")?.Value; parsedContent.Base = contentElement.Attribute(_xml + "base")?.Value; return(true); }
private static bool TryFormatAtom10Content(Atom10Content contentToFormat, out XElement contentElement) { contentElement = default; if (string.IsNullOrEmpty(contentToFormat?.Value)) { return(false); } contentElement = new XElement(_atom + "content"); if (TryFormatValueByType(contentToFormat.Type, contentToFormat.Value, out var contentObject)) { contentElement.Add(contentObject); } if (TryFormatAtom10Type(contentToFormat.Type, skipTypeText: false, out var typeAttribute)) { contentElement.Add(typeAttribute); } if (TryFormatAtom10OptionalTextAttribute(contentToFormat.Src, "src", out var srcAttribute)) { contentElement.Add(srcAttribute); } if (TryFormatAtom10OptionalTextAttribute(contentToFormat.Lang, _xml + "lang", out var langAttribute)) { contentElement.Add(langAttribute); } if (TryFormatAtom10OptionalTextAttribute(contentToFormat.Base, _xml + "base", out var baseAttribute)) { contentElement.Add(baseAttribute); } return(true); }