using System;
using System.IO;
namespace MediaBrowser.Common.Serialization
{
///
/// Provides a wrapper around third party xml serialization.
///
public class XmlSerializer
{
public static void SerializeToStream(T obj, Stream stream)
{
ServiceStack.Text.XmlSerializer.SerializeToStream(obj, stream);
}
public static void SerializeToFile(T obj, string file)
{
using (StreamWriter streamWriter = new StreamWriter(file))
{
ServiceStack.Text.XmlSerializer.SerializeToWriter(obj, streamWriter);
}
}
public static object DeserializeFromFile(Type type, string file)
{
using (Stream stream = File.OpenRead(file))
{
return ServiceStack.Text.XmlSerializer.DeserializeFromStream(type, stream);
}
}
public static T DeserializeFromFile(string file)
{
using (Stream stream = File.OpenRead(file))
{
return ServiceStack.Text.XmlSerializer.DeserializeFromStream(stream);
}
}
public static T DeserializeFromStream(Stream stream)
{
return ServiceStack.Text.XmlSerializer.DeserializeFromStream(stream);
}
public static T DeserializeFromString(string data)
{
return ServiceStack.Text.XmlSerializer.DeserializeFromString(data);
}
}
}