本文整理汇总了C#中IResourceLoader.DownloadAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IResourceLoader.DownloadAsync方法的具体用法?C# IResourceLoader.DownloadAsync怎么用?C# IResourceLoader.DownloadAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IResourceLoader
的用法示例。
在下文中一共展示了IResourceLoader.DownloadAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadAsync
public override Task LoadAsync(IConfiguration configuration, IResourceLoader loader)
{
var link = Link;
var request = link.CreateRequestFor(Url);
var download = loader.DownloadAsync(request);
SetDownload(download);
return link.ProcessResponse(download, response =>
{
var type = link.Type ?? MimeTypeNames.Css;
var engine = configuration.GetStyleEngine(type);
if (engine != null)
{
var options = new StyleOptions
{
Element = link,
IsDisabled = link.IsDisabled,
IsAlternate = link.RelationList.Contains(Keywords.Alternate),
Configuration = configuration
};
_sheet = engine.ParseStylesheet(response, options);
_sheet.Media.MediaText = link.Media ?? String.Empty;
}
});
}
示例2: LoadAsync
/// <summary>
/// See http://www.w3.org/TR/html-imports/#dfn-import-request.
/// </summary>
public override async Task LoadAsync(IConfiguration configuration, IResourceLoader loader)
{
var link = Link;
var document = link.Owner;
var list = ImportLists.GetOrCreateValue(document);
var location = Url;
var request = link.CreateRequestFor(location);
var item = new ImportEntry
{
Relation = this,
IsCycle = CheckCycle(document, location)
};
_isasync = link.HasAttribute(AttributeNames.Async);
list.Add(item);
if (!item.IsCycle)
{
var nestedStatus = new TaskCompletionSource<Boolean>();
var download = loader.DownloadAsync(request);
SetDownload(download);
await link.ProcessResponse(download, async response =>
{
var context = new BrowsingContext(document.Context, Sandboxes.None);
var options = new CreateDocumentOptions(response, configuration)
{
ImportAncestor = document
};
_import = await context.OpenAsync(options, CancellationToken.None).ConfigureAwait(false);
nestedStatus.SetResult(true);
}).ConfigureAwait(false);
await nestedStatus.Task.ConfigureAwait(false);
}
}