DocSpace-client/common/ASC.Data.Backup.Core/Extensions/XmlExtensions.cs

26 lines
606 B
C#
Raw Normal View History

namespace ASC.Data.Backup.Extensions;
public static class XmlExtensions
2020-05-20 15:14:44 +00:00
{
public static string ValueOrDefault(this XElement el)
2020-05-20 15:14:44 +00:00
{
return el?.Value;
}
2020-05-20 15:14:44 +00:00
public static string ValueOrDefault(this XAttribute attr)
{
return attr?.Value;
}
2020-05-20 15:14:44 +00:00
public static void WriteTo(this XElement el, Stream stream)
{
WriteTo(el, stream, Encoding.UTF8);
}
2020-05-20 15:14:44 +00:00
public static void WriteTo(this XElement el, Stream stream, Encoding encoding)
{
var data = encoding.GetBytes(el.ToString(SaveOptions.None));
stream.Write(data, 0, data.Length);
2020-05-20 15:14:44 +00:00
}
}