예제 #1
0
        public bool IsMemberIgnored(Type sourceType, PropertyOrFieldInfo destinationProperty)
        {
            if (mapper.Options.Conventions.IgnoreMemberAttributeShouldBeRespected)
              {
            var ignoreAttribute = destinationProperty.GetCustomAttributes(typeof(IgnoreMemberAttribute), false).SingleOrDefault() as IgnoreMemberAttribute;

            if (ignoreAttribute != null)
            {
              var ignore = true;

              if (!string.IsNullOrEmpty(ignoreAttribute.Profile))
              {
            ignore &= ignoreAttribute.Profile == mapper.Profile;
              }

              if (ignoreAttribute.WhenSourceTypeIs != null)
              {
            ignore &= ignoreAttribute.WhenSourceTypeIs == sourceType;
              }

              if (ignore) return true;
            }
              }
              return false;
        }