public static MapperProfile CreateMapByExpression(this MapperProfile profile, Type type, int size, Action <ITypeConfigSyntax <object> > action) { if (action is null) { throw new ArgumentNullException(nameof(action)); } var expression = new TypeConfigExpression <object>(type, profile.Name, size); action(expression); profile.AddMappingFactory(expression); return(profile); }
public static MapperProfile CreateMapByAttribute(this MapperProfile profile, Type type, bool validation) { if (type is null) { throw new ArgumentNullException(nameof(type)); } var mapAttribute = type.GetCustomAttribute <MapAttribute>(); if (mapAttribute is null) { throw new ArgumentException($"No MapAttribute. type=[{type.FullName}]", nameof(type)); } profile.AddMappingFactory(new AttributeMappingFactory(type, mapAttribute, profile.Name, validation)); return(profile); }
public static MapperProfile CreateMapByAttribute(this MapperProfile profile, IEnumerable <Type> types, bool validation) { if (types is null) { throw new ArgumentNullException(nameof(types)); } var targets = types .Where(x => x != null) .Select(x => new { Type = x, Attribute = x.GetCustomAttribute <MapAttribute>() }) .Where(x => x.Attribute != null); foreach (var pair in targets) { profile.AddMappingFactory(new AttributeMappingFactory(pair.Type, pair.Attribute, profile.Name, validation)); } return(profile); }
//-------------------------------------------------------------------------------- // Profile.Multi //-------------------------------------------------------------------------------- public static MapperProfile CreateMapByAttribute(this MapperProfile profile, IEnumerable <Type> types) { return(CreateMapByAttribute(profile, types, true)); }
public static MapperProfile CreateMapByAttribute(this MapperProfile profile, Type type) { return(profile.CreateMapByAttribute(type, true)); }
public static MapperProfile CreateMapByAttribute <T>(this MapperProfile profile, bool validation) { return(profile.CreateMapByAttribute(typeof(T), validation)); }
//-------------------------------------------------------------------------------- // Profile.Single //-------------------------------------------------------------------------------- public static MapperProfile CreateMapByAttribute <T>(this MapperProfile profile) { return(profile.CreateMapByAttribute(typeof(T), true)); }