예제 #1
0
        public bool Deserializar()
        {
            try
            {
                XmlSerializer xmls  = new XmlSerializer(typeof(Cajon <T>));
                XmlTextReader xmlRD = new XmlTextReader(this.RutaArchivo);
                Cajon <T>     c     = (Cajon <T>)xmls.Deserialize(xmlRD);

                // asigno a la instancia lo deserializado //
                this.Capacidad  = c.Capacidad;
                this.PrecioUnit = c.PrecioUnit;
                this.Lista      = c.Lista;

                xmlRD.Close();
                Console.ReadKey();

                return(true);
            }
            catch (Exception e)
            {
                // this = null;
                Console.WriteLine(e.Message);
                return(false);
            }
        }
예제 #2
0
 public static bool ImprimirTicket(this Cajon <Platano> c, string path)
 {
     using (StreamWriter sw = new StreamWriter(path))
     {
         try
         {
             sw.WriteLine(DateTime.Now.ToString());
             sw.WriteLine("PRECIO: " + c.PrecioTotal.ToString());
             return(true);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
             return(false);
         }
     }
 }