Exemple #1
0
        void ThemeParksNames_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            //Now need to get that data and display it on the page
            //check for errors
            if (e.Error == null)
            {
                try
                {
                    //No errors have been passed now need to take this file and parse it
                    //Its in XML format
                    XDocument xdox = XDocument.Parse(e.Result);
                    //need a list for them to be put in to
                    List <ThemeParksClass> ParkList = new List <ThemeParksClass>();
                    XNamespace             ns       = "http://schemas.datacontract.org/2004/07/WCFServiceWebRole1";
                    //Now need to get every element and add it to the list
                    foreach (XElement item in xdox.Descendants(ns + "ThemeParkList"))
                    {
                        ThemeParksClass content = new ThemeParksClass();
                        content.ID            = Convert.ToInt32(item.Element(ns + "id").Value);
                        content.ThemeParkName = item.Element(ns + "name").Value.ToString();
                        ParkList.Add(content);
                    }

                    parkList.ItemsSource = ParkList.ToList();
                }
                catch (Exception ex)
                {
                    txtBlockErrors.Text = ex.Message;
                }
            }
            else
            {
                //There an Error
            }
        }
        void ThemeParksNames_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            //Now need to get that data and display it on the page
            //check for errors
            if (e.Error == null)
            {
                try
                {
                    //No errors have been passed now need to take this file and parse it
                    //Its in XML format
                    XDocument xdox = XDocument.Parse(e.Result);
                    //need a list for them to be put in to
                    List<ThemeParksClass> ParkList = new List<ThemeParksClass>();
                    XNamespace ns = "http://schemas.datacontract.org/2004/07/WCFServiceWebRole1";
                    //Now need to get every element and add it to the list
                    foreach (XElement item in xdox.Descendants(ns + "ThemeParkList"))
                    {
                        ThemeParksClass content = new ThemeParksClass();
                        content.ID = Convert.ToInt32(item.Element(ns+"id").Value);
                        content.ThemeParkName = item.Element(ns+"name").Value.ToString();
                        ParkList.Add(content);
                    }

                    parkList.ItemsSource = ParkList.ToList();
                }
                catch (Exception ex)
                {
                    txtBlockErrors.Text = ex.Message;
                }
            }
            else
            {
                //There an Error
            }
        }