public static bool HasNoTypeTest(LambdaExpression lambda)
            {
                var typesFinder = new TypeTestFinder();

                typesFinder.Visit(lambda.Body);

                return(!typesFinder.TypeTestExists);
            }
        private static void ErrorIfConditionHasTypeTest(LambdaExpression conditionLambda)
        {
            if (TypeTestFinder.HasNoTypeTest(conditionLambda))
            {
                return;
            }

            var condition = conditionLambda.Body.ToReadableString();

            throw new MappingConfigurationException(string.Format(
                                                        CultureInfo.InvariantCulture,
                                                        "Instead of type testing in condition '{0}', configure for a more specific source or target type.",
                                                        condition));
        }
Example #3
0
        private void ErrorIfConditionHasTypeTest(LambdaExpression conditionLambda)
        {
            if ((SourceType?.IsInterface() == true) ||
                TypeTestFinder.HasNoTypeTest(conditionLambda))
            {
                return;
            }

            var condition = conditionLambda.Body.ToReadableString();

            throw new MappingConfigurationException(string.Format(
                                                        CultureInfo.InvariantCulture,
                                                        "Instead of type testing in condition '{0}', " +
                                                        "configure for a more derived source or target type.",
                                                        condition));
        }