Fix kubernetes port name issue
This commit is contained in:
parent
6a8c74e02a
commit
ffb5eb294a
@ -24,8 +24,8 @@
|
|||||||
.Replace("]", "-")
|
.Replace("]", "-")
|
||||||
.Replace(",", "-");
|
.Replace(",", "-");
|
||||||
|
|
||||||
result = result.Trim('-');
|
|
||||||
if (result.Length > maxLength) result = result.Substring(0, maxLength);
|
if (result.Length > maxLength) result = result.Substring(0, maxLength);
|
||||||
|
result = result.Trim('-');
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -3,24 +3,31 @@
|
|||||||
public static class RandomUtils
|
public static class RandomUtils
|
||||||
{
|
{
|
||||||
private static readonly Random random = new Random();
|
private static readonly Random random = new Random();
|
||||||
|
private static readonly object @lock = new object();
|
||||||
|
|
||||||
public static T PickOneRandom<T>(this List<T> remainingItems)
|
public static T PickOneRandom<T>(this List<T> remainingItems)
|
||||||
{
|
{
|
||||||
var i = random.Next(0, remainingItems.Count);
|
lock (@lock)
|
||||||
var result = remainingItems[i];
|
{
|
||||||
remainingItems.RemoveAt(i);
|
var i = random.Next(0, remainingItems.Count);
|
||||||
return result;
|
var result = remainingItems[i];
|
||||||
|
remainingItems.RemoveAt(i);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T[] Shuffled<T>(T[] items)
|
public static T[] Shuffled<T>(T[] items)
|
||||||
{
|
{
|
||||||
var result = new List<T>();
|
lock (@lock)
|
||||||
var source = items.ToList();
|
|
||||||
while (source.Any())
|
|
||||||
{
|
{
|
||||||
result.Add(RandomUtils.PickOneRandom(source));
|
var result = new List<T>();
|
||||||
|
var source = items.ToList();
|
||||||
|
while (source.Any())
|
||||||
|
{
|
||||||
|
result.Add(RandomUtils.PickOneRandom(source));
|
||||||
|
}
|
||||||
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user