public static bool IsRequired(this MemberInfo memberInfo) { var memberMetadata = new MemberInfoMetadata(memberInfo); var isRequired = memberInfo .GetAttribute<RequiredAttribute>() .IsNotNull(); if (memberMetadata.Type.IsNullable() && isRequired) { const string MessageFormat = "Member '{MemberName}' of type '{Type}' declared in '{DeclaringType}' cannot " + "have Required attribute because it is a nullable type."; var message = MessageFormat .NamedFormat( memberMetadata.Name, memberMetadata.Type.FriendlyShortName(), memberMetadata.DeclaringType.FullName); new ArgumentException(message) .Throw(); } return isRequired; }
public static void SetAccessor(MemberInfoMetadata member, IAccessorPropertyMapper m) { if (member.Accessor == Accessors.Field) { m.Access(AccessorHelper.Translate(member.Accessor)); } if (member.MemberType == MemberTypes.Property) { m.Access(Accessor.Property); } }
internal MappedType( Type sourceType, Type mappedType, KeyMemberInfoMetadata key, MemberInfoMetadata version, IEnumerable <PrimitiveMemberInfoMetadata> primitives, IEnumerable <ReferenceMemberInfoMetadata> references, IEnumerable <CollectionMemberInfoMetadata> collections) { Source = sourceType; Mapped = mappedType; Key = key; Version = version; Primitives = primitives; References = references; Collections = collections; }
private CollectionMemberInfoMetadata CreateCollectionPropertyInfoMetadata(MemberInfoMetadata memberInfoMetadata) { return(new CollectionMemberInfoMetadata(memberInfoMetadata)); }
private ReferenceMemberInfoMetadata CreateReferencePropertyInfoMetadata(MemberInfoMetadata memberInfoMetadata) { return(new ReferenceMemberInfoMetadata(memberInfoMetadata)); }
private PrimitiveMemberInfoMetadata CreatePrimitivePropertyInfoMetadata(MemberInfoMetadata memberInfoMetadata) { return(new PrimitiveMemberInfoMetadata(memberInfoMetadata)); }
private bool CustomStrategy(IMemberStrategy memberStrategy, MemberInfoMetadata member) { return ((memberStrategy == null) || memberStrategy.HasToMap(member)); }