Example #1
0
 public static void FapBusiness(this IGuardClause guardClause, Exception exception)
 {
     throw new FapBizException(exception.Message, exception);
 }
Example #2
0
 /// <summary>
 /// Throws an <see cref="ArgumentException"/> if <paramref name="input"/> is negative or zero.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <returns><paramref name="input" /> if the value is not negative or zero.</returns>
 public static float NegativeOrZero([JetBrainsNotNull] this IGuardClause guardClause, float input, [JetBrainsNotNull] string parameterName)
 {
     return(NegativeOrZero <float>(guardClause, input, parameterName));
 }
 /// <summary>
 /// Throws an <see cref="ArgumentOutOfRangeException" /> if <see cref="input" /> is less than <see cref="rangeFrom" /> or greater than <see cref="rangeTo" />.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="rangeFrom"></param>
 /// <param name="rangeTo"></param>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 public static void OutOfRange(this IGuardClause guardClause, DateTime input, string parameterName, DateTime rangeFrom, DateTime rangeTo)
 {
     OutOfRange <DateTime>(guardClause, input, parameterName, rangeFrom, rangeTo);
 }
Example #4
0
 /// <summary>
 /// Throws an <see cref="ArgumentOutOfRangeException" /> if <paramref name="input"/> is less than <paramref name="rangeFrom"/> or greater than <paramref name="rangeTo"/>.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="rangeFrom"></param>
 /// <param name="rangeTo"></param>
 /// <returns><paramref name="input" /> if the value is not out of range.</returns>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 public static float OutOfRange(this IGuardClause guardClause, float input, string parameterName, float rangeFrom, float rangeTo)
 {
     return(OutOfRange <float>(guardClause, input, parameterName, rangeFrom, rangeTo));
 }
Example #5
0
 /// <summary>
 /// Throws an <see cref="ArgumentException" /> if <paramref name="input"/> is negative.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <returns><paramref name="input" /> if the value is not negative.</returns>
 /// <exception cref="ArgumentException"></exception>
 public static decimal Negative([JetBrainsNotNull] this IGuardClause guardClause, decimal input, [JetBrainsNotNull] string parameterName)
 {
     return(Negative <decimal>(guardClause, input, parameterName));
 }
Example #6
0
 /// <summary>
 /// Throws an <see cref="ArgumentOutOfRangeException" /> if <paramref name="input" /> is less than <paramref name="rangeFrom" /> or greater than <paramref name="rangeTo" />.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="rangeFrom"></param>
 /// <param name="rangeTo"></param>
 /// <returns><paramref name="input" /> if the value is inside the given range.</returns>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 public static DateTime OutOfRange([JetBrainsNotNull] this IGuardClause guardClause, DateTime input, [JetBrainsNotNull] string parameterName, DateTime rangeFrom, DateTime rangeTo)
 {
     return(OutOfRange <DateTime>(guardClause, input, parameterName, rangeFrom, rangeTo));
 }
Example #7
0
 /// <summary>
 /// Throws an <see cref="ArgumentOutOfRangeException" /> if <paramref name="input"/> is less than <paramref name="rangeFrom"/> or greater than <paramref name="rangeTo"/>.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="rangeFrom"></param>
 /// <param name="rangeTo"></param>
 /// <returns><paramref name="input" /> if the value is not out of range.</returns>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 public static short OutOfRange(this IGuardClause guardClause, short input, string parameterName, short rangeFrom, short rangeTo)
 {
     return(OutOfRange <short>(guardClause, input, parameterName, rangeFrom, rangeTo));
 }
        /// <summary>
        /// Throws an <see cref="ArgumentException"/> if <paramref name="input"/> is negative or zero.
        /// </summary>
        /// <param name="guardClause"></param>
        /// <param name="input"></param>
        /// <param name="parameterName"></param>
        /// <param name="message">Optional. Custom error message</param>
        /// <returns><paramref name="input" /> if the value is not negative or zero.</returns>
#if NETSTANDARD || NETFRAMEWORK
        public static TimeSpan NegativeOrZero([JetBrainsNotNull] this IGuardClause guardClause,
                                              TimeSpan input,
                                              [JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName,
                                              string?message = null)
        /// <summary>
        /// Throws an <see cref="ArgumentException"/> if <paramref name="input"/> is negative or zero.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="guardClause"></param>
        /// <param name="input"></param>
        /// <param name="parameterName"></param>
        /// <param name="message">Optional. Custom error message</param>
        /// <returns><paramref name="input" /> if the value is not negative or zero.</returns>
#if NETSTANDARD || NETFRAMEWORK
        private static T NegativeOrZero <T>([JetBrainsNotNull] this IGuardClause guardClause,
                                            T input,
                                            [JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName,
                                            string?message = null) where T : struct, IComparable
Example #10
0
 /// <summary>
 /// Throws an <see cref="ArgumentException" /> if <see cref="input" /> is zero.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <exception cref="ArgumentException"></exception>
 public static void Zero(this IGuardClause guardClause, decimal input, string parameterName)
 {
     Zero <decimal>(guardClause, input, parameterName);
 }
Example #11
0
 /// <summary>
 /// Throws an <see cref="ArgumentOutOfRangeException" /> if <see cref="input" /> is less than <see cref="rangeFrom" /> or greater than <see cref="rangeTo" />.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="rangeFrom"></param>
 /// <param name="rangeTo"></param>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 public static void OutOfRange(this IGuardClause guardClause, int input, string parameterName, int rangeFrom, int rangeTo)
 {
     OutOfRange <int>(guardClause, input, parameterName, rangeFrom, rangeTo);
 }
 /// <summary>
 /// Throws an <see cref="ArgumentOutOfRangeException" /> if  any <paramref name="input"/>'s item is less than <paramref name="rangeFrom"/> or greater than <paramref name="rangeTo"/>.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="rangeFrom"></param>
 /// <param name="rangeTo"></param>
 /// <returns><paramref name="input" /> if any item is not out of range.</returns>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 public static IEnumerable <short> OutOfRange([JetBrainsNotNull] this IGuardClause guardClause, IEnumerable <short> input, [JetBrainsNotNull] string parameterName, short rangeFrom, short rangeTo)
 {
     return(OutOfRange <short>(guardClause, input, parameterName, rangeFrom, rangeTo));
 }
 /// <summary>
 /// Throws an <see cref="ArgumentException" /> if <paramref name="input" /> is zero.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <exception cref="ArgumentException"></exception>
 public static void Zero([NotNull] this IGuardClause guardClause, double input, [NotNull] string parameterName)
 {
     Zero <double>(guardClause, input, parameterName);
 }
Example #14
0
 /// <summary>
 ///     Throws an <see cref="ArgumentNullException" /> if <see paramref="input" /> is null.
 ///     Throws an <see cref="ArgumentException" /> if <see paramref="input" /> is an empty string.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <returns>The input for variable initialization.</returns>
 /// <exception cref="ArgumentException">The <paramref name="input" /> expression is invalid.</exception>
 /// <exception cref="ArgumentNullException"></exception>
 /// <exception cref="ArgumentException"></exception>
 public static string NullOrEmpty(this IGuardClause guardClause, Expression <Func <string> > input)
 {
     Guard.Against.Null(input, nameof(input));
     return(Guard.Against.NullOrEmpty(input.Compile()(), input.MemberExpressionName()));
 }
 /// <summary>
 /// Throws an <see cref="ArgumentOutOfRangeException" /> if  any <paramref name="input"/>'s item is less than <paramref name="rangeFrom"/> or greater than <paramref name="rangeTo"/>.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="rangeFrom"></param>
 /// <param name="rangeTo"></param>
 /// <param name="message">Optional. Custom error message</param>
 /// <returns><paramref name="input" /> if any item is not out of range.</returns>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 public static IEnumerable <TimeSpan> OutOfRange([JetBrainsNotNull] this IGuardClause guardClause, IEnumerable <TimeSpan> input, [JetBrainsNotNull] string parameterName, TimeSpan rangeFrom, TimeSpan rangeTo, string?message = null)
 {
     return(OutOfRange <TimeSpan>(guardClause, input, parameterName, rangeFrom, rangeTo, message));
 }
        /// <summary>
        /// Throws an <see cref="ArgumentException" /> if <paramref name="input"/> is negative.
        /// </summary>
        /// <param name="guardClause"></param>
        /// <param name="input"></param>
        /// <param name="parameterName"></param>
        /// <param name="message">Optional. Custom error message</param>
        /// <returns><paramref name="input" /> if the value is not negative.</returns>
        /// <exception cref="ArgumentException"></exception>
#if NETSTANDARD || NETFRAMEWORK
        public static float Negative([JetBrainsNotNull] this IGuardClause guardClause,
                                     float input,
                                     [JetBrainsNotNull][JetBrainsInvokerParameterName] string parameterName,
                                     string?message = null)
Example #17
0
 /// <summary>
 /// Throws an <see cref="ArgumentOutOfRangeException" /> if <paramref name="input" /> is less than <paramref name="rangeFrom" /> or greater than <paramref name="rangeTo" />.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="rangeFrom"></param>
 /// <param name="rangeTo"></param>
 /// <returns><paramref name="input" /> if the value is inside the given range.</returns>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 public static int OutOfRange([JetBrainsNotNull] this IGuardClause guardClause, int input, [JetBrainsNotNull] string parameterName, int rangeFrom, int rangeTo)
 {
     return(OutOfRange <int>(guardClause, input, parameterName, rangeFrom, rangeTo));
 }
 /// <summary>
 /// Throws an <see cref="ArgumentOutOfRangeException" /> if <paramref name="input"/> is less than <paramref name="rangeFrom"/> or greater than <paramref name="rangeTo"/>.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="rangeFrom"></param>
 /// <param name="rangeTo"></param>
 /// <param name="message">Optional. Custom error message</param>
 /// <returns><paramref name="input" /> if the value is not out of range.</returns>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 public static TimeSpan OutOfRange(this IGuardClause guardClause, TimeSpan input, string parameterName, TimeSpan rangeFrom, TimeSpan rangeTo, string?message = null)
 {
     return(OutOfRange <TimeSpan>(guardClause, input, parameterName, rangeFrom, rangeTo, message));
 }
Example #19
0
 /// <summary>
 /// Throws an <see cref="ArgumentOutOfRangeException" /> if <paramref name="input"/> is less than <paramref name="rangeFrom"/> or greater than <paramref name="rangeTo"/>.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="rangeFrom"></param>
 /// <param name="rangeTo"></param>
 /// <returns><paramref name="input" /> if the value is not out of range.</returns>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 public static decimal OutOfRange(this IGuardClause guardClause, decimal input, string parameterName, decimal rangeFrom, decimal rangeTo)
 {
     return(OutOfRange <decimal>(guardClause, input, parameterName, rangeFrom, rangeTo));
 }
 /// <summary>
 /// Throws an <see cref="ArgumentException" /> if <paramref name="input" /> is zero.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="message">Optional. Custom error message</param>
 /// <returns><paramref name="input" /> if the value is not zero.</returns>
 /// <exception cref="ArgumentException"></exception>
 public static float Zero([JetBrainsNotNull] this IGuardClause guardClause, float input, [JetBrainsNotNull] string parameterName, string?message = null)
 {
     return(Zero <float>(guardClause, input, parameterName, message));
 }
Example #21
0
 /// <summary>
 /// Throws an <see cref="ArgumentOutOfRangeException" /> if <paramref name="input"/> is less than <paramref name="rangeFrom"/> or greater than <paramref name="rangeTo"/>.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="rangeFrom"></param>
 /// <param name="rangeTo"></param>
 /// <returns><paramref name="input" /> if the value is not out of range.</returns>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 public static double OutOfRange(this IGuardClause guardClause, double input, string parameterName, double rangeFrom, double rangeTo)
 {
     return(OutOfRange <double>(guardClause, input, parameterName, rangeFrom, rangeTo));
 }
 /// <summary>
 /// Throws an <see cref="ArgumentException" /> if <paramref name="input" /> is zero.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <returns><paramref name="input" /> if the value is not zero.</returns>
 /// <exception cref="ArgumentException"></exception>
 public static TimeSpan Zero([JetBrainsNotNull] this IGuardClause guardClause, TimeSpan input, [JetBrainsNotNull] string parameterName)
 {
     return(Zero <TimeSpan>(guardClause, input, parameterName));
 }
Example #23
0
 /// <summary>
 /// Throws an <see cref="ArgumentException" /> if <paramref name="input"/> is negative.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <returns><paramref name="input" /> if the value is not negative.</returns>
 /// <exception cref="ArgumentException"></exception>
 public static int Negative([JetBrainsNotNull] this IGuardClause guardClause, int input, [JetBrainsNotNull] string parameterName)
 {
     return(Negative <int>(guardClause, input, parameterName));
 }
 /// <summary>
 /// Throws an <see cref="ArgumentException" /> if <paramref name="input"/> is negative.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="message">Optional. Custom error message</param>
 /// <returns><paramref name="input" /> if the value is not negative.</returns>
 /// <exception cref="ArgumentException"></exception>
 public static double Negative([JetBrainsNotNull] this IGuardClause guardClause, double input, [JetBrainsNotNull] string parameterName, string?message = null)
 {
     return(Negative <double>(guardClause, input, parameterName, message));
 }
Example #25
0
 /// <summary>
 /// Throws an <see cref="ArgumentException"/> if <paramref name="input"/> is negative or zero.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <returns><paramref name="input" /> if the value is not negative or zero.</returns>
 public static long NegativeOrZero([JetBrainsNotNull] this IGuardClause guardClause, long input, [JetBrainsNotNull] string parameterName)
 {
     return(NegativeOrZero <long>(guardClause, input, parameterName));
 }
 /// <summary>
 /// Throws an <see cref="ArgumentException"/> if <paramref name="input"/> is negative or zero.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="message">Optional. Custom error message</param>
 /// <returns><paramref name="input" /> if the value is not negative or zero.</returns>
 public static decimal NegativeOrZero([JetBrainsNotNull] this IGuardClause guardClause, decimal input, [JetBrainsNotNull] string parameterName, string?message = null)
 {
     return(NegativeOrZero <decimal>(guardClause, input, parameterName, message));
 }
Example #27
0
 /// <summary>
 /// Throws an <see cref="ArgumentException"/> if <paramref name="input"/> is negative or zero.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <returns><paramref name="input" /> if the value is not negative or zero.</returns>
 public static double NegativeOrZero([JetBrainsNotNull] this IGuardClause guardClause, double input, [JetBrainsNotNull] string parameterName)
 {
     return(NegativeOrZero <double>(guardClause, input, parameterName));
 }
 /// <summary>
 /// Throws an <see cref="ArgumentException"/> if <paramref name="input"/> is negative or zero.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <param name="message">Optional. Custom error message</param>
 /// <returns><paramref name="input" /> if the value is not negative or zero.</returns>
 public static TimeSpan NegativeOrZero([JetBrainsNotNull] this IGuardClause guardClause, TimeSpan input, [JetBrainsNotNull] string parameterName, string?message = null)
 {
     return(NegativeOrZero <TimeSpan>(guardClause, input, parameterName, message));
 }
 /// <summary>
 /// Throws an <see cref="ArgumentException" /> if <see cref="input" /> is zero.
 /// </summary>
 /// <param name="guardClause"></param>
 /// <param name="input"></param>
 /// <param name="parameterName"></param>
 /// <exception cref="ArgumentException"></exception>
 public static void Zero(this IGuardClause guardClause, int input, string parameterName)
 {
     Zero <int>(guardClause, input, parameterName);
 }
Example #30
0
 public static void FapBusiness(this IGuardClause guardClause, string message)
 {
     throw new FapBizException(message);
 }