private Path Learn(object source, object target) { Path path = null; var sourceProps = source.GetProps(); var targetProps = target.GetProps(); var smartConventionInfo = new SmartConventionInfo { SourceType = source.GetType(), TargetType = target.GetType() }; for (var i = 0; i < sourceProps.Count; i++) { var sourceProp = sourceProps[i]; smartConventionInfo.SourceProp = sourceProp; for (var j = 0; j < targetProps.Count; j++) { var targetProp = targetProps[j]; smartConventionInfo.TargetProp = targetProp; if (!Match(smartConventionInfo)) { continue; } if (path == null) { path = new Path { MatchingProps = new Dictionary <string, string> { { smartConventionInfo.SourceProp.Name, smartConventionInfo.TargetProp.Name } } } } ; else { path.MatchingProps.Add(smartConventionInfo.SourceProp.Name, smartConventionInfo.TargetProp.Name); } } } return(path); }
protected virtual bool Match(SmartConventionInfo c) { return(c.SourceProp.Name == c.TargetProp.Name && c.SourceProp.PropertyType == c.TargetProp.PropertyType); }