コード例 #1
0
        static void Main(string[] args)
        {
            Crucero cruceroUno;

            cruceroUno = new Crucero(3, true, "Brasil");

            Transatlantico transatlanticoUno;

            transatlanticoUno = new Transatlantico(3, true, "Australia");

            try
            {
                cruceroUno.Ingresar(new Pasajero("Pollio", "Juan Martin", Pasajero.ERangos.Camarero));
                cruceroUno.Ingresar(new Pasajero("Otero", "Nataniel", Pasajero.ERangos.Cliente));
                cruceroUno.Ingresar(new Pasajero("Rotela", "Gustavo", Pasajero.ERangos.Cocinero));

                transatlanticoUno.Ingresar(new Pasajero("Pollio", "Juan Martin", Pasajero.ERangos.Camarero));
                transatlanticoUno.Ingresar(new Pasajero("Otero", "Nataniel", Pasajero.ERangos.Cliente));
                transatlanticoUno.Ingresar(new Pasajero("Rotela", "Gustavo", Pasajero.ERangos.Cocinero));
                transatlanticoUno.Ingresar(new Pasajero("Martire", "Julian", Pasajero.ERangos.Capitan));
            }
            catch (Exception e)
            {
                Serializador.Texto(e.Message);
            }

            Serializador.XML(transatlanticoUno);
        }
コード例 #2
0
        public static void XML(Transatlantico unTransatlantico)
        {
            XmlSerializer serializador;
            XmlTextWriter escritor;

            try
            {
                using (escritor = new XmlTextWriter("transatlantico.xml", Encoding.UTF8))
                {
                    serializador = new XmlSerializer(typeof(Transatlantico));

                    serializador.Serialize(escritor, unTransatlantico);
                }
            }
            catch (Exception)
            {
                throw new Exception();
            }
        }