コード例 #1
0
        private static bool TryFormatAtom10Source(Atom10Source sourceToFormat, out XElement sourceElement)
        {
            sourceElement = default;

            if (sourceToFormat == null)
            {
                return(false);
            }

            sourceElement = new XElement(_atom + "source");

            if (TryFormatAtom10OptionalTextElement(sourceToFormat.Id, _atom + "id", out var idElement))
            {
                sourceElement.Add(idElement);
            }

            if (TryFormatAtom10TextOptional(sourceToFormat.Title, _atom + "title", out var titleElement))
            {
                sourceElement.Add(titleElement);
            }

            if (TryFormatAtom10TimestampOptional(sourceToFormat.Updated, _atom + "updated", out var updatedElement))
            {
                sourceElement.Add(updatedElement);
            }

            return(sourceElement.HasElements);
        }
コード例 #2
0
        private static bool TryParseAtom10Source(XElement sourceElement, XNamespace atom, out Atom10Source parsedSource)
        {
            parsedSource = default;

            if (sourceElement == null)
            {
                return(false);
            }

            parsedSource = new Atom10Source();

            parsedSource.Id = sourceElement.Element(atom + "id")?.Value.Trim();

            if (TryParseAtom10Text(sourceElement.Element(atom + "title"), out var parsedTitle))
            {
                parsedSource.Title = parsedTitle;
            }

            if (TryParseAtom10Timestamp(sourceElement.Element(atom + "updated"), out var parsedUpdated))
            {
                parsedSource.Updated = parsedUpdated;
            }

            return(true);
        }