Exemplo n.º 1
0
        public static void IsPositive(
            this Param <sbyte> param,
            ZeroSignMode zeroSignMode = ZeroSignMode.ZeroIsNeither)
        {
            if (param.Value > 0)
            {
                return;
            }

            if (param.Value == 0 && zeroSignMode.HasFlag(ZeroSignMode.ZeroIsPositive))
            {
                return;
            }

            Exceptions.ThrowArgumentException(
                param.Name,
                param.Value,
                param.OptsFn,
                "The value must be positive");
        }
Exemplo n.º 2
0
        public static void IsNonNegative(
            this Param <float> param,
            ZeroSignMode zeroSignMode = ZeroSignMode.ZeroIsNeither)
        {
            if (param.Value > 0)
            {
                return;
            }

            if (param.Value == 0 && !zeroSignMode.HasFlag(ZeroSignMode.ZeroIsNegative))
            {
                return;
            }

            Exceptions.ThrowArgumentException(
                param.Name,
                param.Value,
                param.OptsFn,
                "The value must be non-negative");
        }
Exemplo n.º 3
0
        public static void IsNegative(
            this Param <double> param,
            ZeroSignMode zeroSignMode = ZeroSignMode.ZeroIsNeither)
        {
            if (param.Value < 0)
            {
                return;
            }

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (param.Value == 0 && zeroSignMode.HasFlag(ZeroSignMode.ZeroIsNegative))
            {
                return;
            }

            Exceptions.ThrowArgumentException(
                param.Name,
                param.Value,
                param.OptsFn,
                "The value must be negative");
        }