Exemplo n.º 1
0
        public static string ToJson(this Entity entity, bool indent = true)
        {
            var serializer = new MediaSerializer(MediaSerializer.JsonSiren);
            var json       = serializer.Serialize(entity);

            return(indent ? Json.Beautify(json) : json);
        }
Exemplo n.º 2
0
 public static string Serialize(this MediaSerializer serializer, IEntity entity)
 {
     using (var writer = new StringWriter())
     {
         serializer.Serialize(entity, writer);
         return(writer.ToString());
     }
 }
Exemplo n.º 3
0
        public static void Serialize(this MediaSerializer serializer, IEntity entity, Stream stream, Encoding encoding = null)
        {
            var writer = new StreamWriter(stream, encoding ?? Encoding.UTF8);

            serializer.Serialize(entity, writer);
            writer.Flush();
            stream.Flush();
        }