Permalink
Browse files

Added StringUtils.EndsWith and StringUtils.IsNullOrEmpty methods back…

… in with the obsolete attribute. This is to avoid possible issues with third party addins.
  • Loading branch information...
1 parent b087551 commit 6e698dbfce90b82013c56a88df3634d903aea3bc Ryan Boggs committed Dec 1, 2011
Showing with 37 additions and 0 deletions.
  1. +37 −0 src/NAnt.Core/Util/StringUtils.cs
@@ -41,6 +41,43 @@ public sealed class StringUtils {
#region Public Static Methods
+ /// <summary>
+ /// Determines whether the last character of the given <see cref="string" />
+ /// matches the specified character.
+ /// </summary>
+ /// <param name="value">The string.</param>
+ /// <param name="c">The character.</param>
+ /// <returns>
+ /// <see langword="true" /> if the last character of <paramref name="value" />
+ /// matches <paramref name="c" />; otherwise, <see langword="false" />.
+ /// </returns>
+ /// <exception cref="ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
+ [Obsolete ("StringUtils.EndsWith method is depreciated. Use string.EndsWith(string) instead.")]
+ public static bool EndsWith(string value, char c) {
+ if (value == null)
+ throw new ArgumentNullException("value");
+
+ int stringLength = value.Length;
+ if ((stringLength != 0) && (value[stringLength - 1] == c)) {
+ return true;
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// Indicates whether or not the specified <see cref="string" /> is
+ /// <see langword="null" /> or an <see cref="string.Empty" /> string.
+ /// </summary>
+ /// <param name="value">The value to check.</param>
+ /// <returns>
+ /// <see langword="true" /> if <paramref name="value" /> is <see langword="null" />
+ /// or an empty string (""); otherwise, <see langword="false" />.
+ /// </returns>
+ [Obsolete ("StringUtils.IsNullOrEmpty method is depreciated. Use System.String.IsNullOrEmpty(string) instead.")]
+ public static bool IsNullOrEmpty(string value) {
+ return (value == null || value.Length == 0);
+ }
+
/// <summary>
/// Converts an empty string ("") to <see langword="null" />.
/// </summary>

0 comments on commit 6e698db

Please sign in to comment.