示例#1
0
        public async void SetContent()
        {
            //makes a new JsonChild object from webservice class
            JsonChild child = await webservice.GetChildData();

            //creates the label using information from JsonChild Class
            Label name = new Label
            {
                Text = child.firstname
            };
            Label lastName = new Label
            {
                Text = child.lastname
            };
            Label username = new Label
            {
                Text = child.username
            };
            Label age = new Label
            {
                Text = child.age.ToString()
            };
            Label points = new Label
            {
                Text = child.points.ToString()
            };

            //Adds each label to the stack
            infoStack.Children.Add(name);
            infoStack.Children.Add(lastName);
            infoStack.Children.Add(username);
            infoStack.Children.Add(age);
            infoStack.Children.Add(points);
        }
示例#2
0
        public async Task <JsonChild> GetChildData()
        {
            string tUrl = URL + "ReturnChildData";
            //makes a dictionary using the global variables class.
            Dictionary <string, string> postData = new Dictionary <string, string>()
            {
                { "username", GlobalVariables.username }
            };
            //encodes the dictionary
            var content = new FormUrlEncodedContent(postData);
            //sends and recieves the response from the webservice
            var response = await Client.PostAsync(tUrl, content);

            var responseString = await response.Content.ReadAsStringAsync();

            //deserialises the response into the JsonChild Object created and returns the returned child
            JsonChild returnedChild = JsonConvert.DeserializeObject <JsonChild>(responseString);

            return(returnedChild);
        }