using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; using NzbDrone.Common.EnsureThat.Resources; namespace NzbDrone.Common.EnsureThat { public static class EnsureCollectionExtensions { [DebuggerStepThrough] public static Param HasItems(this Param param) where T : class, ICollection { if (param.Value == null || param.Value.Count < 1) { throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection); } return param; } [DebuggerStepThrough] public static Param> HasItems(this Param> param) { if (param.Value == null || param.Value.Count < 1) { throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection); } return param; } [DebuggerStepThrough] public static Param> HasItems(this Param> param) { if (param.Value == null || !param.Value.Any()) { throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection); } return param; } [DebuggerStepThrough] public static Param HasItems(this Param param) { if (param.Value == null || param.Value.Length < 1) { throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection); } return param; } [DebuggerStepThrough] public static Param> HasItems(this Param> param) { if (param.Value == null || param.Value.Count < 1) { throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection); } return param; } [DebuggerStepThrough] public static Param> HasItems(this Param> param) { if (param.Value == null || param.Value.Count < 1) { throw ExceptionFactory.CreateForParamValidation(param.Name, ExceptionMessages.EnsureExtensions_IsEmptyCollection); } return param; } } }