Skip to content

Commit 3edab65

Browse files
committed
Refactor StringExtensions
1 parent e7c8df7 commit 3edab65

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

QRCoder/Framework4.0Methods/String4Methods.cs renamed to QRCoder/Extensions/StringExtensions.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
using System;
2-
31
namespace QRCoder
42
{
5-
internal static class String40Methods
3+
internal static class StringExtensions
64
{
75
/// <summary>
86
/// Indicates whether the specified string is null, empty, or consists only of white-space characters.
97
/// </summary>
108
/// <returns>
119
/// <see langword="true"/> if the <paramref name="value"/> is null, empty, or white space; otherwise, <see langword="false"/>.
1210
/// </returns>
13-
public static bool IsNullOrWhiteSpace(String value)
11+
public static bool IsNullOrWhiteSpace(this string value)
1412
{
1513
#if NET35
1614
if (value == null) return true;
1715

1816
for (int i = 0; i < value.Length; i++)
1917
{
20-
if (!Char.IsWhiteSpace(value[i])) return false;
18+
if (!char.IsWhiteSpace(value[i])) return false;
2119
}
2220

2321
return true;

QRCoder/PayloadGenerator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,7 @@ private string TimeToString()
20302030

20312031
private void ProcessCommonFields(StringBuilder sb)
20322032
{
2033-
if (String40Methods.IsNullOrWhiteSpace(Secret))
2033+
if (Secret.IsNullOrWhiteSpace())
20342034
{
20352035
throw new Exception("Secret must be a filled out base32 encoded string");
20362036
}
@@ -2039,7 +2039,7 @@ private void ProcessCommonFields(StringBuilder sb)
20392039
string escapedLabel = null;
20402040
string label = null;
20412041

2042-
if (!String40Methods.IsNullOrWhiteSpace(Issuer))
2042+
if (!Issuer.IsNullOrWhiteSpace())
20432043
{
20442044
if (Issuer.Contains(":"))
20452045
{
@@ -2048,7 +2048,7 @@ private void ProcessCommonFields(StringBuilder sb)
20482048
escapedIssuer = Uri.EscapeDataString(Issuer);
20492049
}
20502050

2051-
if (!String40Methods.IsNullOrWhiteSpace(Label))
2051+
if (!Label.IsNullOrWhiteSpace())
20522052
{
20532053
if (Label.Contains(":"))
20542054
{

0 commit comments

Comments
 (0)