Serializare/ Deserializare

 

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));

Advertisements

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 )

Google+ photo

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

Connecting to %s