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