Thursday, April 16, 2015

SerializationUtility

using System.Linq;
using System.Text;
using System.Web.UI;

namespace BusinessObjects.Utils
{
    public class SerializationUtility
    {
        public static string Serialize(object obj)
        {
            var sw = new StringWriter(new StringBuilder());
            var formatter = new LosFormatter();
            formatter.Serialize(sw, obj);
            return sw.ToString();
        }

        public static object Deserialize(string data)
        {
            if (data == null)
                return null;
            return (new LosFormatter()).Deserialize(data);
        }
    }
}

No comments:

Post a Comment