[mono-android] Being driven insane....
Jack Bond
jackhanbond at hotmail.com
Wed Nov 23 12:36:01 EST 2011
Similiar to a previous poster, but this is what I use to serial objects to
store in Intents...
public class SimpleSerializer
{
public static T DeserializeObject<T>(string source)
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
StringReader sr = null;
try
{
sr = new StringReader(source);
T result = (T)serializer.Deserialize(sr);
return result;
}
finally
{
Memory.DisposeGarbage(sr);
}
}
public static string SerializeObject(object target)
{
XmlSerializer serialize = new XmlSerializer(target.GetType());
StringWriter sw = null;
try
{
sw = new StringWriter();
serialize.Serialize(sw, target);
string result = sw.ToString();
return result;
}
finally
{
Memory.DisposeGarbage(sw);
}
}
}
--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/Being-driven-insane-tp5016975p5017416.html
Sent from the Mono for Android mailing list archive at Nabble.com.
More information about the Monodroid
mailing list