我是Reactive Extension初學者。 Gideon Engelberth在我的問題中給了我很好的關於Reactive Extension的答案。如何將IObservable <Unit>返回值分配給XDocument實例
How to convert img url to BASE64 string in HTML on one method chain by using LINQ or Rx
現在我有怎樣的IObservable返回值分配給的XDocument實例的第二個問題。
吉迪恩給了我以下樣品。
public IObservable<Unit> ReplaceImageLinks(XDocument document)
{
return (from element in GetImages(document)
let address = new Uri(element.Attribute("src").Value)
select (from data in DownloadAsync(address)
select Convert.ToBase64String(data)
).Do(base64 => element.Attribute("src").Value = base64)
).Merge()
.IgnoreElements()
.Select(s => Unit.Default);
}
我想這樣做。芽這似乎很難...
public void Convert(XDocument input, out XDocument output)
{
output = ReplaceImageLinks(input);
}