I m a Reactive Extension beginner. Gideon Engelberth gave me excellent answer about Reactive Extension in my question.
< a href=" https://stackoverflow.com/ questions/8897769/how-to-convert-img-url-to- base64-base64-string-in-html-on-one-method-one-method- by- using- lin" 如何使用 LINQ 或 Rx
现在我要问第二个问题, 如何为 XDocument 实例指定 IOO 可观返回值 。
吉迪安给了我贝洛样本
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);
}