forked from ThomasArdal/NuGetPackageVisualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraphHelper.cs
33 lines (28 loc) · 1.06 KB
/
GraphHelper.cs
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
using System.Collections.Generic;
using System.Linq;
namespace NuGetPackageVisualizer
{
public static class GraphHelper
{
public static string GenerateBackgroundColor(IEnumerable<PackageViewModel> packages, PackageViewModel package, IColorConfiguration colors)
{
if (VersionMismatch(package))
{
return colors.VersionMismatchPackageColor;
}
if (HasSamePackageInDifferentVersion(packages, package))
{
return colors.PackageHasDifferentVersionsColor;
}
return colors.DefaultColor;
}
private static bool HasSamePackageInDifferentVersion(IEnumerable<PackageViewModel> packages, PackageViewModel package)
{
return packages.Any(p => p.NugetId == package.NugetId && p.LocalVersion != package.LocalVersion);
}
private static bool VersionMismatch(PackageViewModel package)
{
return package.LocalVersion != package.RemoteVersion;
}
}
}