Tipsy little box

Just another weblog

Serializare/ Deserializare March 7, 2011

Filed under: ASP.NET, C# — evacion @ 3:40 pm

 

public static string SerObjXML(object rspJ, Type type)
         {
             string serObj = null;

             MemoryStream ms = new MemoryStream();
             XmlSerializer bf1 = new XmlSerializer(type);
             bf1.Serialize(ms, rspJ);
             ms.Position = 0;
             StreamReader sr = new StreamReader(ms);
             serObj = sr.ReadToEnd();

             return serObj;
         }

  public static object DeSerObjXML(string xml, Type type)
         {
             XmlSerializer xs = new XmlSerializer(type);
             MemoryStream memoryStream = new MemoryStream(StringToUTF8ByteArray(xml));
             XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
             return xs.Deserialize(memoryStream);
         }

string returnReqXMLss = Common.SerObjXML(sRspData, typeof(JacobClasess.Search.SearchResponseData));

Advertisement
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.