private static bool AttemptConstructorMatch(Type type, ConstructorInfo constructor, List <TypeMemberInfo> memberInfoList, IDictionary <TypeMemberInfo, object> data, out object result) { Dictionary <ParameterInfo, TypeMemberInfo> paramMap; if (constructor.Parameters().Count == 0) { paramMap = new Dictionary <ParameterInfo, TypeMemberInfo>(); result = AttemptCreation(constructor); if (result == null) { return(false); } } else { paramMap = ParameterMapper.MapTypeMembersToParameters(type, constructor.Parameters(), memberInfoList, true); var paramValues = BuildParameterValues(paramMap.Keys.ToList(), paramMap.Values.ToList(), data); result = AttemptCreation(constructor, paramValues); if (result == null) { // Now we make a second and much more forgiving attempt at matching our data to the parameters paramMap = ParameterMapper.MapTypeMembersToParameters(type, constructor.Parameters(), memberInfoList); paramValues = BuildParameterValues(paramMap.Keys.ToList(), paramMap.Values.ToList(), data); result = AttemptCreation(constructor, paramValues); } if (result == null) { return(false); } } Cache.AddMappingFor(type, memberInfoList, new ConstructorMap(constructor, paramMap.Keys.ToList(), paramMap.Values.ToList())); return(true); }