internal MemberValueContractImpl(ObjectMember member, Type declaringType)
        {
            _member             = member ?? throw new ArgumentNullException(nameof(member));
            _lazyCallingHandler = new Lazy <ObjectCallerBase>(() => SafeObjectHandleSwitcher.Switch(AlgorithmKind.Precision)(declaringType));

            DeclaringType = declaringType;
            MemberKind    = member.Kind;
            IsBasicType   = member.MemberType.IsBasicType();

            _reflectorProvider = member.MemberType.GetReflector();
            _attributes        = _reflectorProvider.GetCustomAttributes();
            IncludeAnnotations = HasValidationAnnotationDefined(_attributes);
        }
Example #2
0
        public VerifiableMemberContract(Type declaringType, FieldInfo field)
        {
            _verifiableMemberContractImpl = null;
            DeclaringType = declaringType;
            MemberKind    = VerifiableMemberKind.Field;
            IsBasicType   = field.FieldType.IsBasicType();

            _propertyInfo = null;
            _fieldInfo    = field;

            _reflectorProvider = field.GetReflector();
            _attributes        = _reflectorProvider.GetCustomAttributes();
            IncludeAnnotations = HasValidationAnnotationDefined(_attributes);
        }
        public VerifiableObjectContract(
            Type type,
            Dictionary <string, VerifiableMemberContract> memberContracts)
        {
            _verifiableObjectContractImpl = null;
            Type        = type ?? throw new ArgumentNullException(nameof(type));
            ObjectKind  = type.GetObjectKind();
            IsBasicType = ObjectKind == VerifiableObjectKind.BasicType;

            _memberContracts = memberContracts ?? throw new ArgumentNullException(nameof(memberContracts));
            _valueKeys       = _memberContracts.Keys.ToArray();

            _reflectorProvider        = Type.GetReflector();
            _attributes               = _reflectorProvider.GetCustomAttributes();
            IncludeAnnotationsForType = HasValidationAnnotationDefined(_attributes);
        }
Example #4
0
 public static IEnumerable <T> GetCustomAttributes <T>(this ICustomAttributeReflectorProvider provider) where T : Attribute
 {
     return(provider.GetCustomAttributes(typeof(T)).Select(i => i as T));
 }