/// <summary> /// Deploys this instance. /// </summary> public void Deploy(PropertyMapGenerationOptions __options = PropertyMapGenerationOptions.none) { if (__options != PropertyMapGenerationOptions.none) { Options = __options; } if (FromType.hasParameterlessConstructor()) { FromDefaultInstance = FromType.getInstance(null); } if (ToType.hasParameterlessConstructor()) { ToDefaultInstance = ToType.getInstance(null); } if (Options.HasFlag(PropertyMapGenerationOptions.doAutoMapping)) { // fromProps.Select(x => toProps.ContainsKey(x.Key)); if (Options.HasFlag(PropertyMapGenerationOptions.matchName)) { List <String> matchFromList = fromProps.Keys.Where(x => toProps.ContainsKey(x)).ToList(); foreach (var k in matchFromList) { PropertyMapLink link = PropertyMapLink.Create(fromProps[k], toProps[k], this); if (link != null) { Links.Add(link); } } } } }
/// <summary> /// Adds the link. /// </summary> /// <param name="sourceProperty">The source property.</param> /// <param name="targetProperty">The target property.</param> /// <param name="flags">The flags.</param> /// <returns>Null if source or target property was not found</returns> public PropertyMapLink AddLink(String sourceProperty, String targetProperty, PropertyMapLinkFlags flags = PropertyMapLinkFlags.none) { PropertyInfo f_pi = null; PropertyInfo t_pi = null; if (Options.HasFlag(PropertyMapGenerationOptions.ignoreCase)) { f_pi = fromProps.Search(sourceProperty, StringComparison.InvariantCultureIgnoreCase, true).FirstOrDefault(); t_pi = toProps.Search(targetProperty, StringComparison.InvariantCultureIgnoreCase, true).FirstOrDefault(); } else { if (!fromProps.ContainsKey(sourceProperty)) { return(null); } if (!toProps.ContainsKey(targetProperty)) { return(null); } f_pi = fromProps[sourceProperty]; //, StringComparison.InvariantCultureIgnoreCase, true).FirstOrDefault(); t_pi = toProps[targetProperty]; //, StringComparison.InvariantCultureIgnoreCase, true).FirstOrDefault(); } if (f_pi == null || t_pi == null) { return(null); } if (ContainsLink(f_pi, t_pi)) { return(null); } PropertyMapLink link = PropertyMapLink.Create(f_pi, t_pi, this, flags); if (link != null) { Links.Add(link); } return(link); }