Skip to content

Commit

Permalink
Added string.NotNullNotEmpty(). Method string.IsNullOrEmpty() renamed…
Browse files Browse the repository at this point in the history
… to NullOrEmpty.
  • Loading branch information
grandsilence committed Jan 30, 2019
1 parent e8af6d3 commit 6689675
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Leaf.Core/Extensions/String/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace Leaf.Core.Extensions.String
/// </summary>
public static class StringExtensions
{
public const string HttpProto = "http://";
public const string HttpsProto = "https://";

/// <summary>
/// Проверяет строку, является ли она ссылкой с протоколом http:// или https://.
/// </summary>
Expand All @@ -22,7 +25,7 @@ public static bool IsWebLink(this string self, bool trim = false)
if (trim)
link = link.Trim();

return link.StartsWith("http://") || link.StartsWith("https://");
return link.StartsWith(HttpProto) || link.StartsWith(HttpsProto);
}

/// <summary>
Expand All @@ -37,7 +40,13 @@ public static bool IsWebLink(this string self, bool trim = false)
/// Расширение для метода <see cref="string.IsNullOrEmpty"/>.
/// </summary>
/// <param name="self">Строка</param>
public static bool IsNullOrEmpty(this string self) => string.IsNullOrEmpty(self);
public static bool NullOrEmpty(this string self) => string.IsNullOrEmpty(self);

/// <summary>
/// Инвертированный вызов <see cref="string.IsNullOrEmpty"/>.
/// </summary>
/// <returns>Вернет <see langword="true"/> если строка не является пустой или <see langword="null"/>.</returns>
public static bool NotNullNotEmpty(this string self) => !string.IsNullOrEmpty(self);

/// <summary>
/// Проверка строки на полезный контент.
Expand Down

0 comments on commit 6689675

Please sign in to comment.