mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 03:05:42 +00:00
Remove internal Random in favour of static Shared
This commit is contained in:
parent
684fba043f
commit
b6ec67d91f
@ -30,7 +30,7 @@ public static class ListExtensions
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
}
|
||||
|
||||
random ??= RandomExtensions.Random;
|
||||
random ??= System.Random.Shared;
|
||||
return random.NextFrom(source);
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ public static class ListExtensions
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
}
|
||||
|
||||
random ??= RandomExtensions.Random;
|
||||
random ??= System.Random.Shared;
|
||||
|
||||
int count = source.Count;
|
||||
while (count > 0)
|
||||
|
@ -9,8 +9,6 @@ namespace X10D;
|
||||
/// </summary>
|
||||
public static class RandomExtensions
|
||||
{
|
||||
internal static readonly Random Random = new();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a random value that defined in a specified enum.
|
||||
/// </summary>
|
||||
|
@ -317,11 +317,6 @@ public static class StringExtensions
|
||||
throw new ArgumentNullException(nameof(source));
|
||||
}
|
||||
|
||||
if (random is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(random));
|
||||
}
|
||||
|
||||
if (length < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(length), ExceptionMessages.LengthGreaterThanOrEqualTo0);
|
||||
@ -331,6 +326,8 @@ public static class StringExtensions
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
random ??= Random.Shared;
|
||||
|
||||
char[] array = source.ToCharArray();
|
||||
var builder = new StringBuilder(length);
|
||||
@ -411,7 +408,7 @@ public static class StringExtensions
|
||||
/// <returns>Returns a <see cref="string" /> containing the characters in <paramref name="value" />, rearranged.</returns>
|
||||
public static string Shuffled(this string value)
|
||||
{
|
||||
return value.Shuffled(RandomExtensions.Random);
|
||||
return value.Shuffled(Random.Shared);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user