APIを使用してxmlファイルからデータを解析しています。1 回の API 呼び出しでほとんどのデータを解析できます。各オブジェクトには、簡単に解析できる Title、source、comment、action、objectkey、およびその他のプロパティがあります。ただし、画像プロパティも必要です。画像はxmlファイルにリストされていませんが、オブジェクトキーは、2番目のAPI呼び出しで使用して画像を解析できます。各オブジェクトが 2 番目の API 呼び出しからの画像を含むすべてのプロパティを持つように、同じリストボックスにバインドできるようにするにはどうすればよいですか?
誰かが、Async が進むべき道かもしれないと言いましたが、私にはわかりません....
XDocument streamFeed = XDocument.Load(new StringReader(response.Content));
var data = from query in streamFeed.Descendants("interaction")
select new Interaction
{
title = (string)query.Element("title"),
displayName = (string)query.Element("displayName"),
action = (string)query.Element("action"),
userId = (string)query.Element("userId"),
objectKey = ((string)query.Element("objectKey")),
timestamp = (string)query.Element("timestamp"),
comment = (string)query.Element("comment"),
source = (string)query.Element("source"),
image = getImage() ---> I imagine the second api call here
};
streamListBox.ItemsSource = data;
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
});
}
public string getImage(string key)
{
api calls here =>
{
try
{
//MessageBox.Show(response.Content);
XDocument streamFeed = XDocument.Load(new StringReader(response.Content));
var data2 = from query in streamFeed.Descendants("movie")
select new Object
{
image = (string)query.Element("image"),
};
//streamListBox.ItemsSource = data2;
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
// MessageBox.Show(image);
});
return image;
}