예제 #1
0
        /// <summary>
        ///		Extension method that allows for <see cref="IntegralRangeBase{TIntegralType}.IsNotWithin"/>
        ///		to be called on a <see cref="Int16"/> subject with the range and exclusivity passed as a
        ///		parameter, rather than on the <see cref="IntegralRangeBase{TIntegralType}"/> object
        ///		with a <see cref="Int16"/> parameter.
        /// </summary>
        /// <param name="this">
        ///		The subject <see cref="Int16"/> value in which to check against the <paramref name="range"/>
        ///		parameter to determine whether it is within the range, taking into account the exclusivity.
        /// </param>
        /// <param name="range">
        ///		An instance of the type <see cref="Int16Range"/>, describing a range of numeric values in
        ///		which the <paramref name="this"/> subject is to be compared against.
        /// </param>
        /// <param name="exclusivity">
        ///		A value indicating whether to perform the upper and lower bounds comparisons including
        ///		the range's Minimum and Maximum bounds, or to exclude them. This parameter is optional,
        ///		and the default value is <see cref="EndpointExclusivity.Inclusive"/>.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///		Thrown when the specified <paramref name="range"/> is <see langword="null"/>.
        ///	</exception>
        /// <returns>
        ///		A <see cref="Int16"/> value indicating whether or not the <paramref name="this"/> subject
        ///		is within the provided <paramref cref="range"/> parameter, taking into account the
        ///		<see cref="EndpointExclusivity"/> mode via the <paramref name="exclusivity"/> parameter.
        ///		This comparison is the logical inverse of the <see cref="IsNotWithin"/> extension method.
        /// </returns>
        public static bool IsNotWithin(
            this Int16 @this,
            [NotNull] Int16Range range,
            EndpointExclusivity exclusivity = EndpointExclusivity.Inclusive)
        {
            range.IsNotNull(nameof(range));

            return(range
                   .IsNotWithin(
                       @this,
                       exclusivity));
        }
        /// <summary>
        ///		Extension method that allows for <see cref="NonIntegralRangeBase{TIntegralType}.IsWithin"/>
        ///		to be called on a <see cref="Decimal"/> subject with the range and exclusivity passed as a
        ///		parameter, rather than on the <see cref="NonIntegralRangeBase{TIntegralType}"/> object
        ///		with a <see cref="Decimal"/> parameter.
        /// </summary>
        /// <param name="this">
        ///		The subject <see cref="Decimal"/> value in which to check against the <paramref name="range"/>
        ///		parameter to determine whether it is within the range, taking into account the exclusivity.
        /// </param>
        /// <param name="range">
        ///		An instance of the type <see cref="DecimalRange"/>, describing a range of numeric values in
        ///		which the <paramref name="this"/> subject is to be compared against.
        /// </param>
        /// <param name="exclusivity">
        ///		A value indicating whether to perform the upper and lower bounds comparisons including
        ///		the range's Minimum and Maximum bounds, or to exclude them. This parameter is optional,
        ///		and the default value is <see cref="EndpointExclusivity.Inclusive"/>.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///		Thrown when the specified <paramref name="range"/> is <see langword="null"/>.
        ///	</exception>
        /// <returns>
        ///		A <see cref="bool"/> value indicating whether or not the <paramref name="this"/> subject
        ///		is within the provided <paramref cref="range"/> parameter, taking into account the
        ///		<see cref="EndpointExclusivity"/> mode via the <paramref name="exclusivity"/> parameter.
        /// </returns>
        public static bool IsWithin(
            this Decimal @this,
            [NotNull] DecimalRange range,
            EndpointExclusivity exclusivity = EndpointExclusivity.Inclusive)
        {
            range.IsNotNull(nameof(range));

            return(range
                   .IsWithin(
                       @this,
                       exclusivity));
        }
예제 #3
0
        /// <summary>
        ///		Extension method that allows for <see cref="IntegralRangeBase{TIntegralType}.IsNotWithin"/>
        ///		to be called on a <see cref="UInt32"/> subject with the range and exclusivity passed as a
        ///		parameter, rather than on the <see cref="IntegralRangeBase{TIntegralType}"/> object
        ///		with a <see cref="UInt32"/> parameter.
        /// </summary>
        /// <param name="this">
        ///		The subject <see cref="UInt32"/> value in which to check against the <paramref name="range"/>
        ///		parameter to determine whether it is within the range, taking into account the exclusivity.
        /// </param>
        /// <param name="range">
        ///		An instance of the type <see cref="UInt32Range"/>, describing a range of numeric values in
        ///		which the <paramref name="this"/> subject is to be compared against.
        /// </param>
        /// <param name="exclusivity">
        ///		A value indicating whether to perform the upper and lower bounds comparisons including
        ///		the range's Minimum and Maximum bounds, or to exclude them. This parameter is optional,
        ///		and the default value is <see cref="EndpointExclusivity.Inclusive"/>.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///		Thrown when the specified <paramref name="range"/> is <see langword="null"/>.
        ///	</exception>
        /// <returns>
        ///		A <see cref="UInt32"/> value indicating whether or not the <paramref name="this"/> subject
        ///		is within the provided <paramref cref="range"/> parameter, taking into account the
        ///		<see cref="EndpointExclusivity"/> mode via the <paramref name="exclusivity"/> parameter.
        ///		This comparison is the logical inverse of the <see cref="IsNotWithin"/> extension method.
        /// </returns>
        public static bool IsNotWithin(
            this UInt32 @this,
            [NotNull] UInt32Range range,
            EndpointExclusivity exclusivity = Inclusive)
        {
            range.IsNotNull(nameof(range));

            return(range
                   .IsNotWithin(
                       @this,
                       exclusivity));
        }
예제 #4
0
    /// <summary>
    ///		Extension method that allows for <see cref="NonIntegralRangeBase{TIntegralType}.IsNotWithin"/> 
    ///		to be called on a <see cref="Double"/> subject with the range and exclusivity passed as a
    ///		parameter, rather than on the <see cref="NonIntegralRangeBase{TIntegralType}"/> object 
    ///		with a <see cref="Double"/> parameter.
    /// </summary>
    /// <param name="this">
    ///		The subject <see cref="Double"/> value in which to check against the <paramref name="range"/>
    ///		parameter to determine whether it is within the range, taking into account the exclusivity.
    /// </param>
    /// <param name="range">
    ///		An instance of the type <see cref="DoubleRange"/>, describing a range of numeric values in 
    ///		which the <paramref name="this"/> subject is to be compared against.
    /// </param>
    /// <param name="exclusivity">
    ///		A value indicating whether to perform the upper and lower bounds comparisons including
    ///		the range's Minimum and Maximum bounds, or to exclude them. This parameter is optional,
    ///		and the default value is <see cref="EndpointExclusivity.Inclusive"/>.
    /// </param>
    /// <exception cref="ArgumentNullException">
    ///		Thrown when the specified <paramref name="range"/> is <see langword="null"/>.
    ///	</exception>
    /// <returns>
    ///		A <see cref="Double"/> value indicating whether or not the <paramref name="this"/> subject
    ///		is within the provided <paramref cref="range"/> parameter, taking into account the 
    ///		<see cref="EndpointExclusivity"/> mode via the <paramref name="exclusivity"/> parameter.
    ///		This comparison is the logical inverse of the <see cref="IsNotWithin"/> extension method.
    /// </returns>
    public static bool IsNotWithin(
      this Double @this,
      [NotNull] DoubleRange range,
      EndpointExclusivity exclusivity = Inclusive)
    {
      range.IsNotNull(nameof(range));

      return range
        .IsNotWithin(
          @this,
          exclusivity);
    }
예제 #5
0
        /// <summary>
        ///		Extension method that allows for <see cref="IntegralRangeBase{TIntegralType}.IsWithin"/>
        ///		to be called on a <see cref="SByte"/> subject with the range and exclusivity passed as a
        ///		parameter, rather than on the <see cref="IntegralRangeBase{TIntegralType}"/> object
        ///		with a <see cref="SByte"/> parameter.
        /// </summary>
        /// <param name="this">
        ///		The subject <see cref="SByte"/> value in which to check against the <paramref name="range"/>
        ///		parameter to determine whether it is within the range, taking into account the exclusivity.
        /// </param>
        /// <param name="range">
        ///		An instance of the type <see cref="SByteRange"/>, describing a range of numeric values in
        ///		which the <paramref name="this"/> subject is to be compared against.
        /// </param>
        /// <param name="exclusivity">
        ///		A value indicating whether to perform the upper and lower bounds comparisons including
        ///		the range's Minimum and Maximum bounds, or to exclude them. This parameter is optional,
        ///		and the default value is <see cref="EndpointExclusivity.Inclusive"/>.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///		Thrown when the specified <paramref name="range"/> is <see langword="null"/>.
        ///	</exception>
        /// <returns>
        ///		A <see cref="bool"/> value indicating whether or not the <paramref name="this"/> subject
        ///		is within the provided <paramref cref="range"/> parameter, taking into account the
        ///		<see cref="EndpointExclusivity"/> mode via the <paramref name="exclusivity"/> parameter.
        /// </returns>
        public static bool IsWithin(
            this SByte @this,
            [NotNull] SByteRange range,
            EndpointExclusivity exclusivity = Inclusive)
        {
            range.IsNotNull(nameof(range));

            return(range
                   .IsWithin(
                       @this,
                       exclusivity));
        }
예제 #6
0
    public static void ThrowIfNotWithin(
      [AssertionCondition(IS_NOT_NULL)] this Double @this,
      [NotNull] DoubleRange range,
      [InvokerParameterName] string elementName,
      EndpointExclusivity exclusivity = Inclusive,
      [CallerMemberName] string callerMemberName = "")
    {
      range.IsNotNull(nameof(range));

      if (range
        .IsNotWithin(
          @this,
          exclusivity))
        throw new ArgumentOutOfRangeException(
          elementName,
          $"Parameter {elementName.SQuote()} passed to the method {callerMemberName.SQuote()} " +
          $"must be within [{range.Minimum} and {range.Maximum}], {exclusivity}ly.");
    }