Ejemplo n.º 1
0
 private string Serialize(Farm farm)
 {
     var serializer = new XmlSerializer(typeof(Farm));
     var writer = new StringWriter();
     serializer.Serialize(writer, farm);
     return writer.ToString();
 }
Ejemplo n.º 2
0
        private Farm BuildFarm()
        {
            var farm = new Farm();

            var rex = new Dog();
            rex.Name = "Rex";
            rex.Birthday = new DateTime(2009, 10, 22);
            farm.Animals.Add(rex);

            var tom = new Cat();
            tom.Name = "Tom";
            tom.Birthday = new DateTime(1940, 6, 15);
            farm.Animals.Add(tom);

            var jerry = new Mouse();
            jerry.Name = "Jerry";
            farm.Animals.Add(jerry);

            return farm;
        }