Beispiel #1
0
        public static bool CheckEquals(this Type input, Type expectedType, bool throwException = false, string errorMessage = "")
        {
            var isValid = (input is not null) && (expectedType != null) && (input == expectedType);

            if (isValid is false && throwException)
            {
                ExceptionThrower.ThrowInvalidValueException(CreateExceptionMessage(errorMessage, Resources.ErrorInvalidType), expectedType);
            }

            return(isValid);
        }
Beispiel #2
0
        public static bool CheckIsCondition <T>(this T input, bool condition, bool throwException = false, string errorMessage = "")
        {
            var isValid = input is not null && condition;

            if (isValid is false && throwException)
            {
                ExceptionThrower.ThrowInvalidValueException <object>(CreateExceptionMessage(errorMessage, Resources.ErrorInvalidValue), input !);
            }

            return(isValid);
        }