Exemplo n.º 1
0
        public static string ToJson(this IJson source, Type type)
        {
            source.BeforeSerialize();
            DataContractJsonSerializer serilializer = new DataContractJsonSerializer(type);

            using (Stream stream = new MemoryStream())
            {
                serilializer.WriteObject(stream, source);
                stream.Flush();
                stream.Position = 0;
                StreamReader reader = new StreamReader(stream);
                return(reader.ReadToEnd());
                //  return HttpUtility.UrlEncode(reader.ReadToEnd());
            }
        }