Ejemplo n.º 1
0
        public string SerializeObject(Colecao toSerialize)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType());

            using (StringWriter textWriter = new StringWriter())
            {
                xmlSerializer.Serialize(textWriter, toSerialize);
                return(textWriter.ToString());
            }
        }
Ejemplo n.º 2
0
 public static string SerializarColecao(this Colecao colecao)
 {
     try
     {
         XmlSerializer xmlSerializer = new XmlSerializer(colecao.GetType());
         using (StringWriter textWriter = new StringWriter())
         {
             xmlSerializer.Serialize(textWriter, colecao);
             return(textWriter.ToString());
         }
     }
     catch (Exception)
     {
         return("");
     }
 }