Task chaining
This commit is contained in:
parent
198e5c886f
commit
e9ec1df01b
@ -17,12 +17,12 @@ namespace Rehau.Sku.Assist
|
||||
return await httpClient.GetStringAsync(uri);
|
||||
}
|
||||
|
||||
public async static Task<IDocument> GetDocument(string source)
|
||||
public async static Task<IDocument> GetDocument(Task<string> source)
|
||||
{
|
||||
IConfiguration config = Configuration.Default;
|
||||
IBrowsingContext context = BrowsingContext.New(config);
|
||||
|
||||
return await context.OpenAsync(req => req.Content(source));
|
||||
return await context.OpenAsync(req => req.Content(source.Result));
|
||||
}
|
||||
|
||||
public static IProduct GetProductFromDocument(IDocument document)
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using AngleSharp.Dom;
|
||||
using ExcelDna.Integration;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
@ -12,7 +12,10 @@ namespace Rehau.Sku.Assist
|
||||
[ExcelFunction]
|
||||
public static async Task<string> RAUNAME(string request)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
Task<string> contentTask = Task.Run(() => SkuAssist.GetContent(request, httpClient));
|
||||
Task<IDocument> documentTask = await contentTask.ContinueWith(content => SkuAssist.GetDocument(content));
|
||||
IProduct product = await documentTask.ContinueWith(doc => SkuAssist.GetProductFromDocument(doc.Result));
|
||||
return product.ToString();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user