AutoMapper.TypeMap.AddBeforeMapAction C# (CSharp) Метод

AddBeforeMapAction() публичный Метод

public AddBeforeMapAction ( LambdaExpression beforeMap ) : void
beforeMap System.Linq.Expressions.LambdaExpression
Результат void
        public void AddBeforeMapAction(LambdaExpression beforeMap)
        {
            _beforeMapActions.Add(beforeMap);
        }

Usage Example

Пример #1
0
        private void IncludeBaseMappings(Type source, Type destination, TypeMap typeMap)
        {
            foreach (var inheritedTypeMap in _typeMaps.Where(t => t.TypeHasBeenIncluded(source, destination)))
            {
                foreach (var inheritedMappedProperty in inheritedTypeMap.GetPropertyMaps().Where(m => m.IsMapped()))
                {
                    var conventionPropertyMap = typeMap.GetPropertyMaps()
                                                .SingleOrDefault(m =>
                                                                 m.DestinationProperty.Name == inheritedMappedProperty.DestinationProperty.Name);

                    if (conventionPropertyMap != null && inheritedMappedProperty.HasCustomValueResolver)
                    {
                        conventionPropertyMap.AssignCustomValueResolver(inheritedMappedProperty.GetSourceValueResolvers().First());
                    }
                    else if (conventionPropertyMap == null)
                    {
                        var propertyMap = new PropertyMap(inheritedMappedProperty);

                        typeMap.AddInheritedPropertyMap(propertyMap);
                    }
                }

                //Include BeforeMap
                if (inheritedTypeMap.BeforeMap != null)
                {
                    typeMap.AddBeforeMapAction(inheritedTypeMap.BeforeMap);
                }
                //Include AfterMap
                if (inheritedTypeMap.AfterMap != null)
                {
                    typeMap.AddAfterMapAction(inheritedTypeMap.AfterMap);
                }
            }
        }