private static bool TryFormatAtom10TextRequired(Atom10Text textToFormat, XName name, out XElement textElement) { textElement = new XElement(name); if (TryFormatValueByType(textToFormat?.Type, textToFormat?.Value, out var contentObject)) { textElement.Add(contentObject); } if (TryFormatAtom10Type(textToFormat?.Type, skipTypeText: true, out var typeAttribute)) { textElement.Add(typeAttribute); } if (TryFormatAtom10OptionalTextAttribute(textToFormat?.Lang, _xml + "lang", out var langAttribute)) { textElement.Add(langAttribute); } if (TryFormatAtom10OptionalTextAttribute(textToFormat?.Base, _xml + "base", out var baseAttribute)) { textElement.Add(baseAttribute); } return(true); }
private static bool TryFormatAtom10TextOptional(Atom10Text textToFormat, XName name, out XElement textElement) { textElement = default; if (string.IsNullOrEmpty(textToFormat?.Value)) { return(false); } textElement = new XElement(name); if (TryFormatValueByType(textToFormat.Type, textToFormat.Value, out var contentObject)) { textElement.Add(contentObject); } if (TryFormatAtom10Type(textToFormat.Type, skipTypeText: true, out var typeAttribute)) { textElement.Add(typeAttribute); } if (TryFormatAtom10OptionalTextAttribute(textToFormat.Lang, _xml + "lang", out var langAttribute)) { textElement.Add(langAttribute); } if (TryFormatAtom10OptionalTextAttribute(textToFormat.Base, _xml + "base", out var baseAttribute)) { textElement.Add(baseAttribute); } return(true); }
private static bool TryParseAtom10Text(XElement textElement, out Atom10Text parsedText) { parsedText = default; if (textElement == null) { return(false); } parsedText = new Atom10Text(); parsedText.Type = textElement.Attribute("type")?.Value ?? "text"; if (!TryParseValueByType(parsedText.Type, textElement, out var parsedValue)) { return(false); } parsedText.Value = parsedValue; parsedText.Lang = textElement.Attribute(_xml + "lang")?.Value; parsedText.Base = textElement.Attribute(_xml + "base")?.Value; return(true); }