26 lines
716 B
C#
26 lines
716 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace TransportGame.Utils
|
|
{
|
|
public static class XmlHelper
|
|
{
|
|
/// <summary>
|
|
/// Deserializes a file
|
|
/// </summary>
|
|
/// <typeparam name="T">Type to deserialize</typeparam>
|
|
/// <param name="filename">File name</param>
|
|
/// <returns>Deserialized object</returns>
|
|
public static T Deserialize<T>(string filename)
|
|
{
|
|
XmlSerializer serializer = new XmlSerializer(typeof(T));
|
|
var stream = new StreamReader(filename);
|
|
return (T)serializer.Deserialize(stream);
|
|
}
|
|
}
|
|
}
|