コード例 #1
0
        static void Main(string[] args)
        {
            List <Dog> dogs = new List <Dog>();

            dogs.Add(new Dog("name1", "breed1", "1", "Flat", "name1"));
            dogs.Add(new Dog("name2", "breed2", "2", "Street", "name2"));
            dogs.Add(new Dog("name3", "breed3", "3", "Home", "name3"));
            dogs.Add(new Dog("name4", "breed4", "4", "Home", "name4"));
            dogs.Add(new Dog("name5", "breed5", "5", "Flat", "name5"));
            dogs.Add(new Dog("name6", "breed6", "6", "Home", "name6"));
            dogs.Add(new Dog("name7", "breed7", "7", "Steet", "name7"));
            dogs.Add(new Dog("name8", "breed8", "8", "Flat", "name8"));
            xmlHelper helper = new xmlHelper();

            helper.WriteListToFile(dogs);
            //Menu();
            Console.ReadLine();
        }
コード例 #2
0
        static void SearchOnPlaceLiving(string place)
        {
            xmlHelper helper   = new xmlHelper();
            XDocument document = helper.GetDogsList();
            var       items    = from element in document.Element("dogs").Elements("dog")
                                 where element.Element("dog").Value == place
                                 select new Dog()
            {
                name        = element.Attribute("name").Value,
                breed       = element.Element("breed").Value,
                age         = element.Element("age").Value,
                placeLiving = element.Element("placeLiving").Value,
                nameOrner   = element.Element("nameOrner").Value
            };

            foreach (var item in items)
            {
                Console.WriteLine(item);
            }
        }