From 08273f800c29ba28bbc00c7be30d3eff9fccfd20 Mon Sep 17 00:00:00 2001 From: David Hall Date: Mon, 30 Dec 2019 10:25:45 -0700 Subject: [PATCH] Added StringHelper.IsNullOrWhiteSpace to account for missing function prior to .NET 4. (#86) --- Core/Extensions/StringHelper.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Core/Extensions/StringHelper.cs b/Core/Extensions/StringHelper.cs index 545bfeeb..d1273c07 100644 --- a/Core/Extensions/StringHelper.cs +++ b/Core/Extensions/StringHelper.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Runtime.InteropServices; using System.Security; using Vanara.InteropServices; @@ -210,6 +211,14 @@ namespace Vanara.Extensions /// public static string GetString(IntPtr ptr, int length, CharSet charSet = CharSet.Auto) => GetString(ptr, charSet, length * GetCharSize(charSet)); + /// Indicates whether a specified string is , empty, or consists only of white-space characters. + /// The string to test. + /// + /// if the parameter is or , or if + /// value consists exclusively of white-space characters. + /// + public static bool IsNullOrWhiteSpace(string value) => value is null || value.All(c => char.IsWhiteSpace(c)); + /// Refreshes the memory block from the unmanaged COM task allocator and copies the contents of a new managed String. /// The address of the first character. /// Receives the new character length of the allocated memory block.