Switched plugin config to use xml

pull/702/head
LukePulverenti Luke Pulverenti luke pulverenti 12 years ago
parent 31357d3298
commit 438d7fc005

@ -164,7 +164,7 @@ namespace MediaBrowser.Common.Plugins
}
else
{
Configuration = JsonSerializer.DeserializeFromFile(ConfigurationType, ConfigurationFilePath) as BasePluginConfiguration;
Configuration = XmlSerializer.DeserializeFromFile(ConfigurationType, ConfigurationFilePath) as BasePluginConfiguration;
Configuration.DateLastModified = File.GetLastWriteTime(ConfigurationFilePath);
}
}

@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
namespace MediaBrowser.Common.Serialization
{
@ -9,14 +10,14 @@ namespace MediaBrowser.Common.Serialization
{
public static void SerializeToStream<T>(T obj, Stream stream)
{
GetSerializer<T>().Serialize(stream, obj);
GetSerializer(typeof(T)).Serialize(stream, obj);
}
public static void SerializeToFile<T>(T obj, string file)
{
using (FileStream stream = new FileStream(file, FileMode.Create))
{
GetSerializer<T>().Serialize(stream, obj);
GetSerializer(typeof(T)).Serialize(stream, obj);
}
}
@ -24,18 +25,26 @@ namespace MediaBrowser.Common.Serialization
{
using (Stream stream = File.OpenRead(file))
{
return (T)GetSerializer<T>().Deserialize(stream);
return (T)GetSerializer(typeof(T)).Deserialize(stream);
}
}
public static object DeserializeFromFile(Type type, string file)
{
using (Stream stream = File.OpenRead(file))
{
return GetSerializer(type).Deserialize(stream);
}
}
public static T DeserializeFromStream<T>(Stream stream)
{
return (T)GetSerializer<T>().Deserialize(stream);
return (T)GetSerializer(typeof(T)).Deserialize(stream);
}
private static System.Xml.Serialization.XmlSerializer GetSerializer<T>()
private static System.Xml.Serialization.XmlSerializer GetSerializer(Type type)
{
return new System.Xml.Serialization.XmlSerializer(typeof(T));
return new System.Xml.Serialization.XmlSerializer(type);
}
}
}

Loading…
Cancel
Save