| 1234567891011121314151617181920212223242526272829303132 |
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System.Numerics;
- using System.Xml;
- using System.Xml.Linq;
- using System.Xml.Serialization;
- namespace Infrastructure
- {
- public static class XmlHelper
- {
- public static T DeserializeXmlFile<T>(string filePath)
- {
- try
- {
- XmlSerializer serializer = new XmlSerializer(typeof(T));
- using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
- {
- return (T)serializer.Deserialize(fileStream);
- }
- }
- catch (Exception ex)
- {
- throw new Exception($"Error deserializing XML file: {ex.Message}");
- //return default(T);
- }
- return default(T);
- }
- }
- }
|