public void Map(string inlineEditProperty = null) { var fromType = FromModel.GetType(); var fromProperties = fromType.GetProperties(BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance); var toType = ToModel.GetType(); var toProperties = toType.GetProperties(BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance); // if include list is not null then only update property in the list if (!string.IsNullOrWhiteSpace(inlineEditProperty)) { toProperties = toProperties.Where(w => w.Name == inlineEditProperty).ToArray(); } foreach (var toPropertyInfo in toProperties) { var fromPropertyInfo = fromProperties.SingleOrDefault(w => w.Name == toPropertyInfo.Name); if (fromPropertyInfo == null) { continue; } HandleBool(toPropertyInfo, fromPropertyInfo.GetValue(FromModel, null)); HandleInt(toPropertyInfo, fromPropertyInfo.GetValue(FromModel, null)); HandleString(toPropertyInfo, fromPropertyInfo.GetValue(FromModel, null)); HandleDateTime(toPropertyInfo, fromPropertyInfo.GetValue(FromModel, null)); } }
public ToFro(FromModel fromModel, FromObject fromObject) { FromModel = fromModel; FromObject = fromObject; }