using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace SelfHelpClient.Utils
|
|
{
|
|
public static class XmlUtil
|
|
{
|
|
public static T DeserializeFromFile<T>(string fileName)
|
|
where T : new()
|
|
{
|
|
if (!File.Exists(fileName))
|
|
return new T();
|
|
using (var reader = new StreamReader(fileName))
|
|
{
|
|
var xs = new XmlSerializer(typeof(T));
|
|
object obj = xs.Deserialize(reader);
|
|
reader.Close();
|
|
return (T)obj;
|
|
}
|
|
}
|
|
}
|
|
}
|