示例#1
0
        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);
            }
        }
示例#2
0
        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);
        }
示例#3
0
 public bool ContainsDestinationColumn(string destinationColumn)
 {
     return(DestinationToSource.ContainsKey(destinationColumn) && SourceToDestination.ContainsValue(destinationColumn));
 }
示例#4
0
 public bool ContainsSourceColumn(string sourceColumn)
 {
     return(SourceToDestination.ContainsKey(sourceColumn) && DestinationToSource.ContainsValue(sourceColumn));
 }
示例#5
0
 public void RemoveDestinationColumn(string destinationColumn)
 {
     ClearColumnTransforms(DestinationToSource[destinationColumn]);
     SourceToDestination.Remove(DestinationToSource[destinationColumn]);
     DestinationToSource.Remove(destinationColumn);
 }
示例#6
0
 public void RemoveSourceColumn(string sourceColumn)
 {
     ClearColumnTransforms(sourceColumn);
     DestinationToSource.Remove(SourceToDestination[sourceColumn]);
     SourceToDestination.Remove(sourceColumn);
 }
示例#7
0
 public void Clear()
 {
     SourceToDestination.Clear();
     DestinationToSource.Clear();
     ColumnTransforms.Clear();
 }