private Path Learn(object source, object target) { Path path = null; var sourceProps = source.GetProps(); var targetProps = target.GetProps(); var sci = new SmartConventionInfo { SourceType = source.GetType(), TargetType = target.GetType() }; for (var i = 0; i < sourceProps.Count(); i++) { var s = sourceProps.ElementAt(i); sci.SourceProp = s; for (var j = 0; j < targetProps.Count(); j++) { var t = targetProps.ElementAt(j); sci.TargetProp = t; if (!this.Match(sci)) continue; if (path == null) path = new Path { Source = sci.SourceType, Target = sci.TargetType, Pairs = new Dictionary<string, string> { { sci.SourceProp.Name, sci.TargetProp.Name } } }; else path.Pairs.Add(sci.SourceProp.Name, sci.TargetProp.Name); } } return path; }
protected virtual bool Match(SmartConventionInfo c) { return c.SourceProp.Name == c.TargetProp.Name; }
protected abstract bool Match(SmartConventionInfo c);