forked from Xamla/ROS.NET
-
Notifications
You must be signed in to change notification settings - Fork 2
/
RosMessageBasePackageExtensions.cs
38 lines (30 loc) · 1.4 KB
/
RosMessageBasePackageExtensions.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
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Linq;
using NuGet.Packaging.Core;
using NuGet.Versioning;
namespace YAMLParser
{
public static class RosMessageBasePackageExtensions
{
private const string MESSAGE_BASE_PACKAGE_ID = "Uml.Robotics.Ros.MessageBase";
private const string MESSAGE_BASE_PACKAGE_VERSION = "1.0.7";
public static PackageIdentity MessageBasePackage { get; } = new PackageIdentity(MESSAGE_BASE_PACKAGE_ID, NuGetVersion.Parse(MESSAGE_BASE_PACKAGE_VERSION));
public static bool HasRosMessageBasePackage(this IEnumerable<PackageIdentity> packages)
{
if (packages == null) throw new ArgumentNullException(nameof(packages));
return packages.Any(p => p.IsRosMessageBasePackage());
}
public static IList<PackageIdentity> AddRosMessageBasePackage(this IList<PackageIdentity> packages)
{
if (packages == null) throw new ArgumentNullException(nameof(packages));
packages.Insert(0, MessageBasePackage);
return packages;
}
public static bool IsRosMessageBasePackage(this PackageIdentity package)
{
if (package == null) throw new ArgumentNullException(nameof(package));
return string.Equals(package.Id, MESSAGE_BASE_PACKAGE_ID, StringComparison.InvariantCultureIgnoreCase);
}
}
}