(#44) Replace string.Randomize overloads with optional parameter

This commit is contained in:
Oliver Booth 2021-07-20 17:32:05 +01:00
parent 4bf295a028
commit f268cf5b02
No known key found for this signature in database
GPG Key ID: A4AC17007530E9B4
1 changed files with 2 additions and 22 deletions

View File

@ -251,34 +251,14 @@ namespace X10D
/// </summary> /// </summary>
/// <param name="source">The pool of characters to use.</param> /// <param name="source">The pool of characters to use.</param>
/// <param name="length">The length of the new string returned.</param> /// <param name="length">The length of the new string returned.</param>
/// <param name="random">The <see cref="System.Random" /> supplier.</param>
/// <returns> /// <returns>
/// A new string whose length is equal to <paramref name="length" /> which contains randomly selected characters from /// A new string whose length is equal to <paramref name="length" /> which contains randomly selected characters from
/// <paramref name="source" />. /// <paramref name="source" />.
/// </returns> /// </returns>
/// <exception cref="ArgumentNullException"><paramref name="source" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentNullException"><paramref name="source" /> is <see langword="null" />.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="length" /> is less than 0.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="length" /> is less than 0.</exception>
public static string Randomize(this string source, int length) public static string Randomize(this string source, int length, Random? random = null)
{
return source.Randomize(length, RandomExtensions.Random);
}
/// <summary>
/// Returns a new string of a specified length by randomly selecting characters from the current string.
/// </summary>
/// <param name="source">The pool of characters to use.</param>
/// <param name="length">The length of the new string returned.</param>
/// <param name="random">The <see cref="System.Random" /> supplier.</param>
/// <returns>
/// A new string whose length is equal to <paramref name="length" /> which contains randomly selected characters from
/// <paramref name="source" />.
/// </returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="source" /> is <see langword="null" />.
/// -or-
/// <paramref name="random" /> is <see langword="null" />.
/// </exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="length" /> is less than 0.</exception>
public static string Randomize(this string source, int length, Random random)
{ {
if (source is null) if (source is null)
{ {