Beispiel #1
0
        private MemberInfo GetSourceName(List <MemberInfo> sourceMembers, MemberInfo targetMember, BindingConfig bindingConfig)
        {
            if (bindingConfig != null)
            {
                var sourceName = bindingConfig.GetBindField(targetMember.Name);
                if (sourceName != null)
                {
                    return(sourceMembers.FirstOrDefault(x => x.Name.Equals(sourceName)));
                }
            }
            var matchSourceMembers = sourceMembers.Where(x => _config.NameMatching(targetMember.Name, x.Name));

            if (matchSourceMembers.Count() <= 1)
            {
                return(matchSourceMembers.FirstOrDefault());
            }
            switch (_config.MultiMatchHandle)
            {
            case MultiMatchHandle.Ignore:
                return(null);

            case MultiMatchHandle.Error:
                throw new Exception($"找到多个匹配的成员。TargetMemberName:{targetMember.Name}");

            default:
                return(matchSourceMembers.FirstOrDefault());
            }
        }
Beispiel #2
0
 private bool IsIgnore(MemberInfo targetMember, BindingConfig bindingConfig)
 {
     if (bindingConfig != null)
     {
         var sourceName = bindingConfig.GetBindField(targetMember.Name);
         if (sourceName != null)
         {
             return(false);
         }
         if (bindingConfig.IsIgnoreTargetField(targetMember.Name))
         {
             return(true);
         }
     }
     if (_config.IsGlobalIgnore(targetMember))
     {
         return(true);
     }
     return(false);
 }