コード例 #1
0
        // REF.: https://github.com/arkiq/AppDataBind/blob/master/App9databind2/MainPage.xaml.cs
        public List <Dashpost> parseJArray2List(JsonArray tempJson)
        {
            List <Dashpost> tempList = new List <Dashpost>();

            foreach (var item in tempJson)
            {
                var obj = item.GetObject();

                Dashpost dashPost = new Dashpost();

                foreach (var key in obj.Keys)
                {
                    IJsonValue value;
                    if (!obj.TryGetValue(key, out value))
                    {
                        continue;
                    }

                    switch (key)
                    {
                    case "title":
                        dashPost.Title = value.GetString();
                        break;

                    case "desc":
                        dashPost.Description = value.GetString();
                        break;
                    }
                } // inner foreach

                tempList.Add(dashPost);
            } // outter foreach
            return(tempList);
        }     // end of json to collection converter
コード例 #2
0
        private async Task <Dashpost> NewDashpostDialog(string title)
        {
            ContentDialog dial = new DashboardAddForm();
            var           titl = (TextBox)GetChildren((Grid)dial.Content, 0, 1);
            var           desc = (TextBox)GetChildren((Grid)dial.Content, 1, 1);

            if (await dial.ShowAsync() == ContentDialogResult.Primary)
            {
                var dashpost = new Dashpost();

                dashpost.Title       = titl.Text;
                dashpost.Description = desc.Text;

                return(dashpost);
            }

            return(null);
        }