-
Notifications
You must be signed in to change notification settings - Fork 748
Expand file tree
/
Copy pathRemoteSourceDependencyInfo.cs
More file actions
98 lines (83 loc) · 3.08 KB
/
RemoteSourceDependencyInfo.cs
File metadata and controls
98 lines (83 loc) · 3.08 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// 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.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using NuGet.Packaging;
using NuGet.Packaging.Core;
using NuGet.Shared;
namespace NuGet.Protocol.Core.Types
{
/// <summary>
/// A collection of package dependency groups with the content (nupkg url).
/// </summary>
public class RemoteSourceDependencyInfo : IEquatable<RemoteSourceDependencyInfo>
{
/// <summary>
/// DependencyInfo
/// </summary>
/// <param name="identity">package identity</param>
/// <param name="dependencyGroups">package dependency groups</param>
/// <param name="contentUri">The content uri for the dependency.</param>
public RemoteSourceDependencyInfo(
PackageIdentity identity,
bool listed,
IEnumerable<PackageDependencyGroup> dependencyGroups,
string contentUri)
{
if (identity == null)
{
throw new ArgumentNullException(nameof(identity));
}
if (dependencyGroups == null)
{
throw new ArgumentNullException(nameof(dependencyGroups));
}
if (contentUri == null)
{
throw new ArgumentNullException(nameof(contentUri));
}
Identity = identity;
Listed = listed;
DependencyGroups = dependencyGroups.ToList();
ContentUri = contentUri;
}
/// <summary>
/// Package identity
/// </summary>
public PackageIdentity Identity { get; }
/// <summary>
/// IsListed
/// </summary>
public bool Listed { get; }
/// <summary>
/// Package dependency groups
/// </summary>
public IEnumerable<PackageDependencyGroup> DependencyGroups { get; }
/// <summary>
/// The content url of this resource.
/// </summary>
public string ContentUri { get; set; }
public bool Equals(RemoteSourceDependencyInfo? other)
{
return other != null &&
Identity.Equals(other.Identity) &&
new HashSet<PackageDependencyGroup>(DependencyGroups).SetEquals(other.DependencyGroups) &&
string.Equals(ContentUri, other.ContentUri, StringComparison.Ordinal);
}
public override bool Equals(object? obj) => Equals(obj as RemoteSourceDependencyInfo);
public override int GetHashCode()
{
var combiner = new HashCodeCombiner();
combiner.AddObject(Identity);
combiner.AddUnorderedSequence(DependencyGroups);
combiner.AddObject(ContentUri);
return combiner.CombinedHash;
}
public override string ToString()
{
return String.Format(CultureInfo.InvariantCulture, "{0} : {1}", Identity, String.Join(" ,", DependencyGroups));
}
}
}