namespace XmlFactory public static class XmlSerialization public stati

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
namespace XmlFactory
{
public static class XmlSerialization
{
public static string Serialize (object serializableClass, Type classType)
{
XmlSerializer xmlSerializer = new XmlSerializer(classType);
StringWriter stringWriter = new StringWriter();
xmlSerializer.Serialize(stringWriter, serializableClass);
return stringWriter.ToString();
}
public static object Deserialize (Type classType, string serializedValue)
{
XmlSerializer xmlSerializer = new XmlSerializer(classType);
StringReader stringReader = new StringReader(serializedValue);
return xmlSerializer.Deserialize(stringReader);
}
}
}