Пример #1
0
 private void WebResponseCallback(IAsyncResult result)
 {
     JPosts jPosts;
     try
     {
         HttpWebRequest request = ((HttpWebRequest)result.AsyncState);
         StreamReader sr = new StreamReader(request.EndGetResponse(result).GetResponseStream());
         string data = sr.ReadToEnd();
         jPosts = JsonConvert.DeserializeObject<JPosts>(data);
     }
     catch
     {
         jPosts = new JPosts();
     }
     CallbackMethod(jPosts);
 }
Пример #2
0
        private void PostData(JPosts jPosts)
        {
            Dispatcher.BeginInvoke(() => {
                 webStackPanel.Children.Clear();
                 blogStackPanel.Children.Clear();
                 if (jPosts.Webs.Length != 0)
                     web_noinfo.Visibility = Visibility.Collapsed;
                 if (jPosts.Blogs.Length != 0)
                     blog_noinfo.Visibility = Visibility.Collapsed;
                 for (int i = 0; i < jPosts.Webs.Length; i++)
                    webStackPanel.Children.Add(createInfoWebItem(jPosts.Webs[i]));

                 for (int i = 0; i < jPosts.Blogs.Length; i++)
                    blogStackPanel.Children.Add(createInfoBlogItem(jPosts.Blogs[i]));

             });
        }