示例#1
0
        public DVCMenu() : base(null, true)
        {
            Root = new RootElement("ServiceStack Test")
            {
                new Section()
                {
                    new StringElement("Parse Weather API", () => {
                        using (System.Net.WebClient wc = new System.Net.WebClient())
                        {
                            // Query the Yahoo weather api for the Boston MA forecast using yql
                            var yql     = System.Web.HttpUtility.UrlPathEncode("select item from weather.forecast where location=\"USMA0046\"&format=json");
                            string json = wc.DownloadString("http://query.yahooapis.com/v1/public/yql?q=" + yql);

                            // Dump in console the recieved Json response
                            Console.WriteLine(json);

                            // Parse the Json into the POCO classes
                            var jsonInfo = JsonSerializer.DeserializeFromString <RootObject>(json);

                            weatherViewController = new WeatherViewController(jsonInfo);
                        }
                        NavigationController.PushViewController(weatherViewController, true);
                    })
                }
            };
        }
示例#2
0
        public DVCMenu()
            : base(null, true)
        {
            Root = new RootElement ("ServiceStack Test") {
                new Section () {
                    new StringElement ("Parse Weather API", ()=> {
                        using (System.Net.WebClient wc = new System.Net.WebClient())
                        {
                            // Query the Yahoo weather api for the Boston MA forecast using yql
                            var yql = System.Web.HttpUtility.UrlPathEncode ("select item from weather.forecast where location=\"USMA0046\"&format=json");
                            string json = wc.DownloadString ("http://query.yahooapis.com/v1/public/yql?q=" + yql);

                            // Dump in console the recieved Json response
                            Console.WriteLine (json);

                            // Parse the Json into the POCO classes
                            var jsonInfo = JsonSerializer.DeserializeFromString<RootObject>(json);

                            weatherViewController = new WeatherViewController (jsonInfo);
                        }
                        NavigationController.PushViewController (weatherViewController, true);
                    })
                }
            };
        }