This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-nitride-cil/src/MfGames.Nitride.Feeds/Structure/AtomHelper.cs

31 lines
614 B
C#
Raw Normal View History

2021-09-07 05:15:45 +00:00
using System.Xml.Linq;
2022-09-06 05:53:22 +00:00
namespace MfGames.Nitride.Feeds.Structure;
/// <summary>
/// Helper methods for working with XML elements.
/// </summary>
public static class AtomHelper
2021-09-07 05:15:45 +00:00
{
2022-07-09 04:52:10 +00:00
public static void AddIfSet(
XElement root,
XElement? elem)
2021-09-07 05:15:45 +00:00
{
if (elem != null)
2021-09-07 05:15:45 +00:00
{
root.Add(elem);
2021-09-07 05:15:45 +00:00
}
}
2021-09-07 05:15:45 +00:00
2022-07-09 04:52:10 +00:00
public static void AddIfSet(
XElement elem,
string name,
string? text)
{
if (!string.IsNullOrWhiteSpace(text))
2021-09-07 05:15:45 +00:00
{
elem.Add(new XElement(XmlConstants.AtomNamespace + name, new XText(text)));
2021-09-07 05:15:45 +00:00
}
}
}