-
Notifications
You must be signed in to change notification settings - Fork 160
/
Tags.cs
65 lines (54 loc) · 1.3 KB
/
Tags.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
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Linq;
namespace Steeltoe.Connector.Services;
public class Tags
{
public Tags(string tag)
: this(new string[] { tag })
{
}
public Tags(string[] tags)
{
if (tags == null)
{
Values = System.Array.Empty<string>();
}
else
{
Values = tags;
}
}
internal Tags()
{
}
public IEnumerable<string> Values { get; internal protected set; }
public bool ContainsOne(IEnumerable<string> tags)
{
return tags != null && Values != null && tags.Intersect(Values).Any();
}
public bool Contains(string tag)
{
if (Values == null)
{
return false;
}
return Values.Contains(tag);
}
public bool StartsWith(string tag)
{
if (tag != null && Values != null)
{
foreach (var t in Values)
{
if (tag.StartsWith(t))
{
return true;
}
}
}
return false;
}
}