/* Copyright 2007-2013 The NGenerics Team (https://github.com/ngenerics/ngenerics/wiki/Team) This program is licensed under the GNU Lesser General Public License (LGPL). You should have received a copy of the license along with the source code. If not, an online copy of the license can be found at http://www.gnu.org/copyleft/lesser.html. */ using System; namespace NGenerics.Util { /// /// Performs common argument validation. /// public static class Guard { #region Methods /// /// Checks a string argument to ensure it isn't null or empty. /// /// The argument value to check. /// The name of the argument. /// is a null reference. /// is . public static void ArgumentNotNullOrEmptyString(string argumentValue, string argumentName) { ArgumentNotNull(argumentValue, argumentName); if (argumentValue.Length == 0) { throw new ArgumentException("String cannot be empty.", argumentName); } } /// /// Checks an argument to ensure it isn't null. /// /// The argument value to check. /// The name of the argument. /// is a null reference. public static void ArgumentNotNull(object argumentValue, string argumentName) { if (argumentValue == null) { throw new ArgumentNullException(argumentName); } } #endregion } }