Exemple #1
0
 public bool PassesCtorValidation() =>
 DisableConstructorValidation ||
 ConstructExpression != null ||
 DestinationCtor != null ||
 ConstructDestinationUsingServiceLocator ||
 ConstructorMap?.CanResolve == true ||
 DestinationTypeToUse.IsInterface() ||
 DestinationTypeToUse.IsAbstract() ||
 DestinationTypeToUse.IsGenericTypeDefinition() ||
 DestinationTypeToUse.IsValueType() ||
 DestinationTypeDetails.Constructors.FirstOrDefault(c => c.GetParameters().All(p => p.IsOptional)) != null;
Exemple #2
0
        public bool PassesCtorValidation()
        {
            if (DisableConstructorValidation)
            {
                return(true);
            }

            if (DestinationCtor != null)
            {
                return(true);
            }

            if (ConstructDestinationUsingServiceLocator)
            {
                return(true);
            }

            if (ConstructorMap?.CanResolve == true)
            {
                return(true);
            }

            if (DestinationTypeToUse.IsInterface())
            {
                return(true);
            }

            if (DestinationTypeToUse.IsAbstract())
            {
                return(true);
            }

            if (DestinationTypeToUse.IsGenericTypeDefinition())
            {
                return(true);
            }

            if (DestinationTypeToUse.IsValueType())
            {
                return(true);
            }

            var constructors = DestinationTypeToUse
                               .GetDeclaredConstructors()
                               .Where(ci => !ci.IsStatic);

            //find a ctor with only optional args
            var ctorWithOptionalArgs = constructors.FirstOrDefault(c => c.GetParameters().All(p => p.IsOptional));

            return(ctorWithOptionalArgs != null);
        }
Exemple #3
0
 internal LambdaExpression CreateMapperLambda(IConfigurationProvider configurationProvider, HashSet <TypeMap> typeMapsPath) =>
 SourceType.IsGenericTypeDefinition() || DestinationTypeToUse.IsGenericTypeDefinition() ?
 null :
 new TypeMapPlanBuilder(configurationProvider, this).CreateMapperLambda(typeMapsPath);