示例#1
0
        /// <summary>
        ///		Extension method that allows for <see cref="NonIntegralRangeBase{TIntegralType}.Constrain"/>
        ///		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 constrain a value within a range with an implicit inclusive comparison mode.
        /// </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>
        /// <exception cref="ArgumentNullException">
        ///		Thrown when the specified <paramref name="range"/> is <see langword="null"/>.
        ///	</exception>
        /// <returns>
        ///		A <see cref="Double"/> value that is the <paramref name="this"/> subject value adjusted to
        ///		force the range of possible values to be within the provided <paramref cref="range"/>
        ///		parameter, using <see cref="EndpointExclusivity.Inclusive"/> as the comparison mode.
        /// </returns>
        public static Double Constrain(
            this Double @this,
            [NotNull] DoubleRange range)
        {
            range.IsNotNull(nameof(range));

            return(range
                   .Constrain(
                       @this));
        }