Skip to content

Commit ac93266

Browse files
committed
Replaced own IsNullOrWhiteSpace with usage of string.IsNullOrWhiteSpace
1 parent 53ee16b commit ac93266

File tree

3 files changed

+4
-47
lines changed

3 files changed

+4
-47
lines changed

FileHelpers.Tests/Tests/Helpers/StringHelperTest.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace FileHelpers.Tests
77
{
88
/// <summary>
9-
/// FileHelpers Helpers StringHelper tests
9+
/// FileHelpers Helpers StringHelper tests
1010
/// </summary>
1111
[TestFixture]
1212
internal class StringHelperTest
@@ -35,16 +35,6 @@ public void RemoveTrailingBlanks()
3535
Check.That(StringHelper.RemoveBlanks(" + 41")).IsEqualTo("+41");
3636
}
3737

38-
[Test(Description = "String IsNullOrWhiteSpace help method tests")]
39-
public void IsNullOrWhiteSpace()
40-
{
41-
Check.That(StringHelper.IsNullOrWhiteSpace(" ")).IsEqualTo(true);
42-
Check.That(StringHelper.IsNullOrWhiteSpace(null)).IsEqualTo(true);
43-
Check.That(StringHelper.IsNullOrWhiteSpace("")).IsEqualTo(true);
44-
Check.That(StringHelper.IsNullOrWhiteSpace(" test ")).IsEqualTo(false);
45-
Check.That(StringHelper.IsNullOrWhiteSpace("test")).IsEqualTo(false);
46-
}
47-
4838
[Test(Description = "String StartsWithIgnoringWhiteSpaces help method tests")]
4939
public void StartsWithIgnoringWhiteSpaces()
5040
{

FileHelpers/Core/RecordOperations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public bool StringToRecord(object record, LineInfo line, object[] values)
121121
private bool MustIgnoreLine(string line)
122122
{
123123
if (mRecordInfo.IgnoreEmptyLines) {
124-
if ((mRecordInfo.IgnoreEmptySpaces && StringHelper.IsNullOrWhiteSpace(line)) ||
124+
if ((mRecordInfo.IgnoreEmptySpaces && string.IsNullOrWhiteSpace(line)) ||
125125
line.Length == 0)
126126
return true;
127127
}

FileHelpers/Helpers/StringHelper.cs

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ internal static CompareInfo CreateComparer()
181181
/// <param name="oldValue">Value to replace</param>
182182
/// <param name="newValue">value to replace with</param>
183183
/// <returns>String with all multiple occurrences replaced</returns>
184-
internal static string ReplaceRecursive(string original, string oldValue, string newValue)
184+
private static string ReplaceRecursive(string original, string oldValue, string newValue)
185185
{
186186
const int maxTries = 1000;
187187

@@ -244,19 +244,7 @@ internal static string ToValidIdentifier(string original)
244244
/// <returns>string with values replaced</returns>
245245
public static string ReplaceIgnoringCase(string original, string oldValue, string newValue)
246246
{
247-
return Replace(original, oldValue, newValue, StringComparison.OrdinalIgnoreCase);
248-
}
249-
250-
/// <summary>
251-
/// String replace with a comparison function, eg OridinalIgnoreCase
252-
/// </summary>
253-
/// <param name="original">Original string</param>
254-
/// <param name="oldValue">Value to be replaced</param>
255-
/// <param name="newValue">value to replace with</param>
256-
/// <param name="comparisionType">Comparison type (enum)</param>
257-
/// <returns>String with values replaced</returns>
258-
public static string Replace(string original, string oldValue, string newValue, StringComparison comparisionType)
259-
{
247+
StringComparison comparisionType = StringComparison.OrdinalIgnoreCase;
260248
string result = original;
261249

262250
if (!string.IsNullOrEmpty(oldValue))
@@ -281,27 +269,6 @@ public static string Replace(string original, string oldValue, string newValue,
281269
return result;
282270
}
283271

284-
/// <summary>
285-
/// Indicates whether a specified string is null, empty, or consists only of white-space characters.
286-
/// </summary>
287-
/// <param name="value">The string to test.</param>
288-
/// <returns>true if the parameter is null, empty, or consists only of white-space characters.</returns>
289-
public static bool IsNullOrWhiteSpace(string value)
290-
{
291-
if (value == null)
292-
{
293-
return true;
294-
}
295-
for (int i = 0; i < value.Length; i++)
296-
{
297-
if (!char.IsWhiteSpace(value[i]))
298-
{
299-
return false;
300-
}
301-
}
302-
return true;
303-
}
304-
305272
/// <summary>
306273
/// Determines whether the beginning of this string instance matches the specified string ignoring white spaces at the start.
307274
/// </summary>

0 commit comments

Comments
 (0)