Tweaked json and jsv serializers

pull/702/head
LukePulverenti Luke Pulverenti luke pulverenti 12 years ago
parent 020c20bd7d
commit a2f120b76b

@ -19,9 +19,9 @@ namespace MediaBrowser.Common.Serialization
{
Configure();
using (StreamWriter streamWriter = new StreamWriter(file))
using (Stream stream = File.Open(file, FileMode.Create))
{
ServiceStack.Text.JsonSerializer.SerializeToWriter<T>(obj, streamWriter);
ServiceStack.Text.JsonSerializer.SerializeToStream<T>(obj, stream);
}
}
@ -52,13 +52,6 @@ namespace MediaBrowser.Common.Serialization
return ServiceStack.Text.JsonSerializer.DeserializeFromStream<T>(stream);
}
public static T DeserializeFromString<T>(string data)
{
Configure();
return ServiceStack.Text.JsonSerializer.DeserializeFromString<T>(data);
}
private static bool IsConfigured = false;
private static void Configure()
{

@ -18,5 +18,21 @@ namespace MediaBrowser.Common.Serialization
{
return ServiceStack.Text.TypeSerializer.DeserializeFromStream<T>(stream);
}
public static void SerializeToFile<T>(T obj, string file)
{
using (Stream stream = File.Open(file, FileMode.Create))
{
ServiceStack.Text.TypeSerializer.SerializeToStream<T>(obj, stream);
}
}
public static T DeserializeFromFile<T>(string file)
{
using (Stream stream = File.OpenRead(file))
{
return ServiceStack.Text.TypeSerializer.DeserializeFromStream<T>(stream);
}
}
}
}

Loading…
Cancel
Save