using System; using System.Collections.Generic; using System.Linq; namespace SpotifyAPI.Web { /// /// Ensure input parameters /// internal static class Ensure { /// /// Checks an argument to ensure it isn't null. /// /// The argument value to check /// The name of the argument public static void ArgumentNotNull(object value, string name) { if (value != null) { return; } throw new ArgumentNullException(name); } /// /// Checks an argument to ensure it isn't null or an empty string /// /// The argument value to check /// The name of the argument public static void ArgumentNotNullOrEmptyString(string value, string name) { if (!string.IsNullOrEmpty(value)) { return; } throw new ArgumentException("String is empty or null", name); } public static void ArgumentNotNullOrEmptyList(IEnumerable value, string name) { if (value != null && value.Any()) { return; } throw new ArgumentException("List is empty or null", name); } } }