forked from menees/Libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStringExtensions.cs
44 lines (36 loc) · 1.34 KB
/
StringExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
namespace Menees
{
#region Using Directives
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text;
#endregion
/// <summary>
/// Adds extension methods to <see cref="string"/>.
/// </summary>
/// <remarks>
/// These methods are properly annotated for nullable analysis, unlike string.IsNullOrEmpty in netstandard2.0 and net48 builds.
/// </remarks>
public static class StringExtensions
{
#region Public Methods
/// <summary>
/// Shortcut for <see cref="string.IsNullOrWhiteSpace"/>. Blank means "null, empty, or whitespace".
/// </summary>
public static bool IsBlank([NotNullWhen(false)] this string? text) => string.IsNullOrWhiteSpace(text);
/// <summary>
/// Shortcut for NOT <see cref="string.IsNullOrWhiteSpace"/>. Blank means "null, empty, or whitespace".
/// </summary>
public static bool IsNotBlank([NotNullWhen(true)] this string? text) => !string.IsNullOrWhiteSpace(text);
/// <summary>
/// Shortcut for <see cref="string.IsNullOrEmpty"/>.
/// </summary>
public static bool IsEmpty([NotNullWhen(false)] this string? text) => string.IsNullOrEmpty(text);
/// <summary>
/// Shortcut for NOT <see cref="string.IsNullOrEmpty"/>.
/// </summary>
public static bool IsNotEmpty([NotNullWhen(true)] this string? text) => !string.IsNullOrEmpty(text);
#endregion
}
}