private void btnExecute_Click(object sender, RoutedEventArgs e)
        {
            HttpClient httpClient = new HttpClient();
            var        response   = httpClient.GetAsync(txtUrl.Text).Result;

            if (response.IsSuccessStatusCode)
            {
                var           content       = response.Content.ReadAsStringAsync().Result;
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(ArrayOfstring));
                ArrayOfstring workspaceList = (ArrayOfstring)xmlSerializer.Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(content)));
                lstWorkspace.ItemsSource = workspaceList.String;
            }
            else
            {
                MessageBox.Show("Error", "Failed to call Tosca REST API!");
            }
        }
Ejemplo n.º 2
0
        public override object ReadObject(XmlReader reader)
        {
            ArrayOfstring ArrayOfstringField = null;
            if (IsParentStartElement(reader, false, true))
            {
                ArrayOfstringField = new ArrayOfstring();
                reader.Read();

                System.Collections.ArrayList string_List = new System.Collections.ArrayList();
                for (int i = 0; (i > -1); i = (i + 1))
                {
                    if (!IsChildStartElement(reader, "string", false, false))
                    {
                        ArrayOfstringField.STRING = new string[string_List.Count];
                        string_List.CopyTo(ArrayOfstringField.STRING);
                        break;
                    }
                    string_List.Add(ReadString(reader));
                }
                reader.ReadEndElement();
            }
            return ArrayOfstringField;
        }