mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-14 16:35:40 +00:00
(#42) throw on null value for string.Base64*code
This commit is contained in:
parent
3e11a209e7
commit
c151a9c754
@ -42,8 +42,14 @@ public static class StringExtensions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The base-64 string to convert.</param>
|
/// <param name="value">The base-64 string to convert.</param>
|
||||||
/// <returns>The plain text string representation of <paramref name="value" />.</returns>
|
/// <returns>The plain text string representation of <paramref name="value" />.</returns>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
public static string Base64Decode(this string value)
|
public static string Base64Decode(this string value)
|
||||||
{
|
{
|
||||||
|
if (value is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
return Convert.FromBase64String(value).ToString(Encoding.ASCII);
|
return Convert.FromBase64String(value).ToString(Encoding.ASCII);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,8 +58,14 @@ public static class StringExtensions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The plain text string to convert.</param>
|
/// <param name="value">The plain text string to convert.</param>
|
||||||
/// <returns>The string representation, in base 64, of <paramref name="value" />.</returns>
|
/// <returns>The string representation, in base 64, of <paramref name="value" />.</returns>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
|
||||||
public static string Base64Encode(this string value)
|
public static string Base64Encode(this string value)
|
||||||
{
|
{
|
||||||
|
if (value is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(value));
|
||||||
|
}
|
||||||
|
|
||||||
return Convert.ToBase64String(value.GetBytes(Encoding.ASCII));
|
return Convert.ToBase64String(value.GetBytes(Encoding.ASCII));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user