コード例 #1
0
 /// <summary>
 /// Method that calls service to polulate Json Posts
 /// </summary>
 private void PopulateJsonPosts()
 {
     //This makes an async call to the service
     Task <List <JsonPostViewObject> > .Factory.StartNew(() =>
     {
         return(ModelToViewObjectConverter.Convert(_service.GetPosts()));
     }).ContinueWith((t) =>
     {
         if (t != null && t.Result != null &&
             t.Result.Count > 0)
         {
             //Polulate results, pump up on UI thread
             if (App.Current != null)
             {
                 App.Current.Dispatcher.BeginInvoke((Action) delegate()
                 {
                     t.Result.ForEach(v => JsonPosts.Add(v));
                     if (JsonPosts != null && JsonPosts.Count > 0)
                     {
                         SelectedJsonPlaceHolder = JsonPosts.FirstOrDefault();
                     }
                 });
             }
             else //Test
             {
                 t.Result.ForEach(v => JsonPosts.Add(v));
                 if (JsonPosts != null && JsonPosts.Count > 0)
                 {
                     SelectedJsonPlaceHolder = JsonPosts.FirstOrDefault();
                 }
             }
         }
     });
 }
コード例 #2
0
        /// <summary>
        /// Just fetch Json Post as per supplied criteria
        /// </summary>
        /// <param name="param"></param>
        private void GetSelectedPost(object param)
        {
            if (_service != null && _selectedJsonPlaceHolder != null)
            {
                JsonPostDetailModel jsonPlaceHolderModel = _service.GetPost(_selectedJsonPlaceHolder.Id);

                if (jsonPlaceHolderModel != null)
                {
                    //Just populate fetched object after service call
                    SelectedJsonPlaceHolder = ModelToViewObjectConverter.Convert(jsonPlaceHolderModel);
                    NotifyPropertyChanged("CopyModeEnabled");
                    RenderPostContentFormat();
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Returns JsonPostViewObject from a JsonPostDetailModel object
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 private static JsonPostDetailModel GetJsonPostDetailModel(JsonPostViewObject viewObject)
 {
     return(new JsonPostDetailModel {
         id = viewObject.Id, title = viewObject.Title, body = viewObject.Body, userId = viewObject.UserId
     });
 }
コード例 #4
0
 /// <summary>
 /// Create a Model object from a View Object
 /// </summary>
 /// <param name="viewObject"></param>
 /// <returns></returns>
 public static JsonPostDetailModel Convert(JsonPostViewObject viewObject)
 {
     return(GetJsonPostDetailModel(viewObject));
 }