-
Notifications
You must be signed in to change notification settings - Fork 748
Expand file tree
/
Copy pathOwnerDetailsUriResourceV3Provider.cs
More file actions
43 lines (37 loc) · 1.74 KB
/
OwnerDetailsUriResourceV3Provider.cs
File metadata and controls
43 lines (37 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#nullable enable
using System;
using System.Threading;
using System.Threading.Tasks;
using NuGet.Protocol.Core.Types;
using NuGet.Protocol.Resources;
namespace NuGet.Protocol.Providers
{
/// <summary>NuGet.Protocol resource provider for <see cref="OwnerDetailsUriTemplateResourceV3"/> in V3 HTTP feeds.</summary>
/// <remarks>When successful, returns an instance of <see cref="OwnerDetailsUriTemplateResourceV3"/>.</remarks>
public class OwnerDetailsUriResourceV3Provider : ResourceProvider
{
public OwnerDetailsUriResourceV3Provider()
: base(typeof(OwnerDetailsUriTemplateResourceV3),
nameof(OwnerDetailsUriTemplateResourceV3),
NuGetResourceProviderPositions.Last)
{
}
/// <inheritdoc cref="ResourceProvider.TryCreate(SourceRepository, CancellationToken)"/>
public override async Task<Tuple<bool, INuGetResource?>> TryCreate(SourceRepository source, CancellationToken token)
{
OwnerDetailsUriTemplateResourceV3? resource = null;
ServiceIndexResourceV3? serviceIndex = await source.GetResourceAsync<ServiceIndexResourceV3>(token);
if (serviceIndex != null)
{
Uri? uriTemplate = serviceIndex.GetServiceEntryUri(ServiceTypes.OwnerDetailsUriTemplate);
if (uriTemplate != null)
{
resource = OwnerDetailsUriTemplateResourceV3.CreateOrNull(uriTemplate);
}
}
return new Tuple<bool, INuGetResource?>(resource != null, resource);
}
}
}