public void Add(string sourceColumn, string destinationColumn, ColumnTransformDelegate columnTransform) { if (string.IsNullOrWhiteSpace(sourceColumn)) { throw new ArgumentNullException(nameof(sourceColumn), "Destination column '" + destinationColumn + "' must have a corresponding source column."); } if (string.IsNullOrWhiteSpace(sourceColumn)) { throw new ArgumentNullException(nameof(destinationColumn), "Source column '" + sourceColumn + "' must have a corresponding destination column."); } if (!ContainsSourceColumn(sourceColumn) && !ContainsDestinationColumn(destinationColumn)) { SourceToDestination.Add(sourceColumn, destinationColumn); DestinationToSource.Add(destinationColumn, sourceColumn); } else if (ContainsSourceColumn(sourceColumn) && GetDestinationColumn(sourceColumn) != destinationColumn) { throw new ArgumentException("The source column '" + sourceColumn + "' cannot be mapped to destination column '" + destinationColumn + "' because it has already been mapped to the column '" + GetDestinationColumn(sourceColumn) + "'."); } else if (ContainsDestinationColumn(destinationColumn) && GetSourceColumn(destinationColumn) != sourceColumn) { throw new ArgumentException("The destination column '" + destinationColumn + "' cannot be mapped to source column '" + sourceColumn + "' because it has already been mapped to the column '" + GetSourceColumn(destinationColumn) + "'."); } if (columnTransform != null) { AddColumnTransform(sourceColumn, columnTransform); } }
protected void FromMember( Expression <Func <TDestination, dynamic> > dtoMember, Expression <Func <TSource, dynamic> > sourceMember ) { MemberMapProfile <TSource, TDestination> profile = new MemberMapProfile <TSource, TDestination>(); profile.SourceMember = sourceMember; profile.DestinationMember = dtoMember; SourceToDestination.Add(profile); }
public bool ContainsDestinationColumn(string destinationColumn) { return(DestinationToSource.ContainsKey(destinationColumn) && SourceToDestination.ContainsValue(destinationColumn)); }
public bool ContainsSourceColumn(string sourceColumn) { return(SourceToDestination.ContainsKey(sourceColumn) && DestinationToSource.ContainsValue(sourceColumn)); }
public void RemoveDestinationColumn(string destinationColumn) { ClearColumnTransforms(DestinationToSource[destinationColumn]); SourceToDestination.Remove(DestinationToSource[destinationColumn]); DestinationToSource.Remove(destinationColumn); }
public void RemoveSourceColumn(string sourceColumn) { ClearColumnTransforms(sourceColumn); DestinationToSource.Remove(SourceToDestination[sourceColumn]); SourceToDestination.Remove(sourceColumn); }
public void Clear() { SourceToDestination.Clear(); DestinationToSource.Clear(); ColumnTransforms.Clear(); }