using System.Xml.Serialization;

namespace DocumentOperator.Infrastructure.Services;

public static class StringExtensions
{
    public static T? DeserializeXml<T>(this string xmlText)
    {
        if (string.IsNullOrWhiteSpace(xmlText))
            return default;

        var serializer = new XmlSerializer(typeof(T));
        using var reader = new StringReader(xmlText);
        return (T?)serializer.Deserialize(reader);
    }
}