本文整理汇总了C#中SourceRepository.GetResourceAsync方法的典型用法代码示例。如果您正苦于以下问题:C# SourceRepository.GetResourceAsync方法的具体用法?C# SourceRepository.GetResourceAsync怎么用?C# SourceRepository.GetResourceAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceRepository
的用法示例。
在下文中一共展示了SourceRepository.GetResourceAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryCreate
public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
{
MetadataResourceV3 curResource = null;
RegistrationResourceV3 regResource = await source.GetResourceAsync<RegistrationResourceV3>(token);
if (regResource != null)
{
var messageHandlerResource = await source.GetResourceAsync<HttpHandlerResource>(token);
DataClient client = new DataClient(messageHandlerResource.MessageHandler);
curResource = new MetadataResourceV3(client, regResource);
}
return new Tuple<bool, INuGetResource>(curResource != null, curResource);
}
示例2: TryCreate
public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
{
UISearchResourceV3 curResource = null;
var serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>(token);
if (serviceIndex != null)
{
var rawSearch = await source.GetResourceAsync<RawSearchResourceV3>(token);
var metadataResource = await source.GetResourceAsync<UIMetadataResource>(token);
curResource = new UISearchResourceV3(rawSearch, metadataResource);
}
return new Tuple<bool, INuGetResource>(curResource != null, curResource);
}
示例3: TryCreate
public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
{
UIMetadataResourceV3 curResource = null;
if (await source.GetResourceAsync<ServiceIndexResourceV3>(token) != null)
{
var regResource = await source.GetResourceAsync<RegistrationResourceV3>();
var reportAbuseResource = await source.GetResourceAsync<ReportAbuseResourceV3>();
// construct a new resource
curResource = new UIMetadataResourceV3(_client, regResource, reportAbuseResource);
}
return new Tuple<bool, INuGetResource>(curResource != null, curResource);
}
示例4: TryCreate
public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
{
PSAutoCompleteResourceV3 curResource = null;
var serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>(token);
if (serviceIndex != null)
{
var regResource = await source.GetResourceAsync<RegistrationResourceV3>(token);
// construct a new resource
curResource = new PSAutoCompleteResourceV3(_client, serviceIndex, regResource);
}
return new Tuple<bool, INuGetResource>(curResource != null, curResource);
}
示例5: TryCreate
public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken cancellationToken)
{
V3TotalsStatsResource totalsStatsResource = null;
var serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>(cancellationToken);
if (serviceIndex != null)
{
// TODO: fix this for resource templates
throw new NotImplementedException();
//ResourceSelector resourceSelector = new ResourceSelector(source);
//IList<Uri> resourceUrls = serviceIndex[ServiceTypes.TotalStats];
//Uri resourceUri = await resourceSelector.DetermineResourceUrlAsync(resourceUrls, cancellationToken);
//var messageHandlerResource = await source.GetResourceAsync<HttpHandlerResource>(cancellationToken);
//DataClient client = new DataClient(messageHandlerResource.MessageHandler);
//// construct a new resource
//totalsStatsResource = new V3TotalsStatsResource(client, resourceUri);
}
return new Tuple<bool, INuGetResource>(totalsStatsResource != null, totalsStatsResource);
}
示例6: TryCreate
public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
{
SearchLatestResourceV3 curResource = null;
ServiceIndexResourceV3 serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>(token);
if (serviceIndex != null)
{
var rawSearch = await source.GetResourceAsync<RawSearchResourceV3>(token);
if (rawSearch != null)
{
curResource = new SearchLatestResourceV3(rawSearch);
}
}
return new Tuple<bool, INuGetResource>(curResource != null, curResource);
}
示例7: TryCreate
public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
{
DependencyInfoResource curResource = null;
if (await source.GetResourceAsync<ServiceIndexResourceV3>(token) != null)
{
var messageHandlerResource = await source.GetResourceAsync<HttpHandlerResource>(token);
var client = new DataClient(messageHandlerResource.MessageHandler);
var regResource = await source.GetResourceAsync<RegistrationResourceV3>(token);
// construct a new resource
curResource = new DependencyInfoResourceV3(client, regResource, source);
}
return new Tuple<bool, INuGetResource>(curResource != null, curResource);
}
示例8: TryCreate
public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
{
RegistrationResourceV3 regResource = null;
var serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>(token);
if (serviceIndex != null)
{
Uri baseUrl = serviceIndex[ServiceTypes.RegistrationsBaseUrl].FirstOrDefault();
var messageHandlerResource = await source.GetResourceAsync<HttpHandlerResource>(token);
DataClient client = new DataClient(messageHandlerResource.MessageHandler);
// construct a new resource
regResource = new RegistrationResourceV3(client, baseUrl);
}
return new Tuple<bool, INuGetResource>(regResource != null, regResource);
}
示例9: TryCreate
public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
{
RawSearchResourceV3 curResource = null;
ServiceIndexResourceV3 serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>();
if (serviceIndex != null)
{
var endpoints = serviceIndex[ServiceTypes.SearchQueryService].ToArray();
if (endpoints.Length > 0)
{
var messageHandlerResource = await source.GetResourceAsync<HttpHandlerResource>(token);
// construct a new resource
curResource = new RawSearchResourceV3(messageHandlerResource.MessageHandler, endpoints);
}
}
return new Tuple<bool, INuGetResource>(curResource != null, curResource);
}
示例10: TryCreate
public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
{
PSSearchResource resource = null;
UISearchResource uiSearchResource = await source.GetResourceAsync<UISearchResource>(token);
if (uiSearchResource != null)
{
resource = new PowerShellSearchResourceV2(uiSearchResource);
}
return new Tuple<bool, INuGetResource>(resource != null, resource);
}
示例11: GetRepository
protected async Task<V2Resource> GetRepository(SourceRepository source, CancellationToken token)
{
var repositoryResource = await source.GetResourceAsync<PackageRepositoryResourceV2>(token);
if (repositoryResource != null && repositoryResource.V2Client != null)
{
return repositoryResource;
}
return null;
}
示例12: TryCreate
public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
{
ApiAppSearchResource resource = null;
var messageHandlerResource = await source.GetResourceAsync<HttpHandlerResource>(token);
ServiceIndexResourceV3 serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>();
if (messageHandlerResource != null && serviceIndex != null)
{
var endpoints = serviceIndex["ApiAppSearchQueryService"];
if (endpoints.Any())
{
RawSearchResourceV3 rawSearch = new RawSearchResourceV3(messageHandlerResource.MessageHandler, endpoints);
resource = new ApiAppSearchResource(rawSearch);
}
}
return new Tuple<bool, INuGetResource>(resource != null, resource);
}
示例13: GetDownloadStream
private static async Task<Stream> GetDownloadStream(SourceRepository sourceRepository, PackageIdentity packageIdentity, CancellationToken token)
{
Stream downloadStream = null;
DownloadResource downloadResource = await sourceRepository.GetResourceAsync<DownloadResource>(token);
if(downloadResource != null)
{
downloadStream = await downloadResource.GetStream(packageIdentity, token);
return downloadStream;
}
return null;
}
示例14: TryCreate
public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository source, CancellationToken token)
{
SimpleSearchResourceV3 curResource = null;
var rawSearch = await source.GetResourceAsync<RawSearchResourceV3>(token);
if (rawSearch != null && rawSearch is RawSearchResourceV3)
{
curResource = new SimpleSearchResourceV3(rawSearch);
}
return new Tuple<bool, INuGetResource>(curResource != null, curResource);
}
示例15: TryCreate
public override async Task<Tuple<bool, INuGetResource>> TryCreate(SourceRepository sourceRepository, CancellationToken token)
{
INuGetResource resource = null;
var serviceIndexResource = await sourceRepository.GetResourceAsync<ServiceIndexResourceV3>();
if (serviceIndexResource != null)
{
resource = new RemoteV3FindPackageByIdResource(sourceRepository);
}
return Tuple.Create(resource != null, resource);
}