using System.Reflection.PortableExecutable;
using System.Xml.Serialization;

namespace WmsMobileServe.Utils;

/// <summary>
/// XML 工具类
/// </summary>
public class XmlUtils
{
    /// <summary>
    /// 格式化xml字符串到实体类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="xmlString"></param>
    /// <returns></returns>
    public static T? Deserialize<T>(string xmlString) where T : class
    {
        try
        {
            using StringReader reader = new(xmlString);
            XmlSerializer xs = new(typeof(T));
            T? ret = xs.Deserialize(reader) as T;
            return ret;
        }
        catch { }
        return default;
    }



}
