public static string GetMemberName(this IMemberModel member, MemberSide side, List <Func <IMemberModel, MemberSide, string?> > getMemberNames, Func <string, string> nameConverter) { var memberName = getMemberNames.Select(func => func(member, side)) .FirstOrDefault(name => name != null) ?? member.Name; return(nameConverter(memberName)); }
public static bool ShouldMapMember(this IMemberModel member, CompileArgument arg, MemberSide side) { var predicates = arg.Settings.ShouldMapMember; var result = predicates.Select(predicate => predicate(member, side)) .FirstOrDefault(it => it != null); if (result != null) { return(result == true); } if (arg.Settings.EnableNonPublicMembers == true) { result = Mapster.ShouldMapMember.AllowNonPublic(member, side); if (result != null) { return(result == true); } } var names = side == MemberSide.Destination ? arg.GetDestinationNames() : arg.GetSourceNames(); return(names.Contains(member.Name)); }
public AdaptMemberAttribute(string name, MemberSide side) { this.Name = name; this.Side = side; }
public AdaptIgnoreAttribute(MemberSide side) { this.Side = side; }
public static bool ShouldMapMember(this IMemberModel member, IEnumerable <Func <IMemberModel, MemberSide, bool?> > predicates, MemberSide side) { return(predicates.Select(predicate => predicate(member, side)) .FirstOrDefault(result => result != null) == true); }