test/Qowaiv.CodeGenerator.UnitTests/Guard.cs
/// <summary>Throws an <see cref="ArgumentOutOfRangeException"/> if the parameter not in the collection, otherwise the parameter is passed.</summary>
/// <typeparam name="T">The type to guard; must be a structure.</typeparam>
/// <param name="parameter">The parameter to guard.</param>
/// <param name="paramName">The name of the parameter.</param>
/// <param name="forbiddenRange">The forbidden range of values.</param>
Throws an  if the parameter not in the collection, otherwise the parameter is passed.
Throws an if the parameter not in the collection otherwise the parameter is passed .
[DebuggerStepThrough]
        public static T NotIn<T>(T parameter, string paramName, params T[] forbiddenRange) where T : struct
        {
            if (forbiddenRange.Contains(parameter))
            {
                var forbidden = string.Join(", ", forbiddenRange);
                throw new ArgumentOutOfRangeException(paramName, string.Format(CultureInfo.CurrentCulture, Messages.ArgumentOutOfRangeException_InCollection, forbidden));
            }
            return parameter;
        }
[ DebuggerStepThrough ] public static T NotIn < T > ( T parameter , string paramName , params T [ ] forbiddenRange ) where T : struct { if ( forbiddenRange . Contains ( parameter ) ) { var forbidden = string . Join ( " " , forbiddenRange ) ; throw new ArgumentOutOfRangeException ( paramName , string . Format ( CultureInfo . CurrentCulture , Messages . ArgumentOutOfRangeException_InCollection , forbidden ) ) ; } return parameter ; }
Throws an  if the parameter not in the collection, otherwise the parameter is passed.
Throws an if the parameter not in the collection otherwise the parameter is passed .
parameter
T
The parameter to guard.
The parameter to guard .
paramName
string
The name of the parameter.
The name of the parameter .
forbiddenRange
The forbidden range of values.
The forbidden range of values .
typeparam
The type to guard; must be a structure.
The type to guard ; must be a structure .