31 lines
945 B
C#
31 lines
945 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml.Linq;
|
|
|
|
namespace EFCDesk.HelpersXml
|
|
{
|
|
public static class XmlHelper
|
|
{
|
|
public static string Value(XElement? parent, XName elementName)
|
|
=> parent?.Element(elementName)?.Value?.Trim() ?? string.Empty;
|
|
|
|
public static string Value(XElement? parent, string elementName)
|
|
=> parent?.Element(elementName)?.Value?.Trim() ?? string.Empty;
|
|
|
|
public static decimal? Decimal(XElement parent, XName elementName)
|
|
{
|
|
var value = Value(parent, elementName);
|
|
if (decimal.TryParse(value, out var result))
|
|
return result;
|
|
|
|
return null;
|
|
}
|
|
|
|
public static List<XElement> Elements(XElement? parent, XName elementName)
|
|
=> parent?.Elements(elementName)?.ToList() ?? new List<XElement>();
|
|
}
|
|
}
|