public bool HasToMap(MemberInfoMetadata memberInfoMetadata) { return (memberInfoMetadata.Type.IsPrimitiveType() || memberInfoMetadata.Type == typeof(byte[]) || memberInfoMetadata.Type.IsNullable()); }
public bool HasToMap(MemberInfoMetadata memberInfoMetadata) { if (new PrimitiveMemberStrategy().HasToMap(memberInfoMetadata)) { return false; } var memberType = memberInfoMetadata.Type; if (memberType.IsOneOf(notAllowedCollectionTypeDictionary)) { return false; } if (memberType.IsEnumerable()) { var genericArguments = memberType.GetGenericArguments(); if (genericArguments.Count() > 1) { return false; } var genericArgument = genericArguments.Single(); return !genericArgument.IsPrimitiveType(); } return false; }
public bool HasToMap(MemberInfoMetadata memberInfoMetadata) { if (new PrimitiveMemberStrategy().HasToMap(memberInfoMetadata)) { return(false); } var memberType = memberInfoMetadata.Type; if (memberType.IsOneOf(notAllowedCollectionTypeDictionary)) { return(false); } if (memberType.IsEnumerable()) { var genericArguments = memberType.GetGenericArguments(); if (genericArguments.Count() > 1) { return(false); } var genericArgument = genericArguments.Single(); return(!genericArgument.IsPrimitiveType()); } return(false); }
public bool HasToMap(MemberInfoMetadata memberInfoMetadata) { return memberInfoMetadata.Type.IsPrimitiveType() || memberInfoMetadata.Type == typeof(byte[]) || memberInfoMetadata.Type.IsNullable(); }
public bool HasToMap(MemberInfoMetadata memberInfoMetadata) { if (memberInfoMetadata.Type == typeof(string)) { return (memberInfoMetadata .GetAttribute <StringLengthAttribute>() .IsNotNull()); } return(false); }
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); } }
public bool HasToMap(MemberInfoMetadata memberInfoMetadata) { if (memberInfoMetadata.Type == typeof(string)) { return memberInfoMetadata .GetAttribute<StringLengthAttribute>() .IsNotNull(); } return false; }
public bool CanBeTheKey(MemberInfoMetadata memberInfoMetadata) { var isAcceptedType = memberInfoMetadata .Type.IsOneOf(typeof(Guid), typeof(int)); if (!isAcceptedType) { return(false); } return (memberInfoMetadata.Name == "Id" || memberInfoMetadata.GetAttribute <KeyAttribute>().IsNotNull()); }
public bool CanBeTheVersion(MemberInfoMetadata memberInfoMetadata) { var isAcceptedType = memberInfoMetadata .Type.IsOneOf(typeof(DateTime), typeof(byte[])); if (!isAcceptedType) { return(false); } return (memberInfoMetadata.Name == "Version" || memberInfoMetadata.GetAttribute <TimestampAttribute>().IsNotNull()); }
public bool CanBeTheKey(MemberInfoMetadata memberInfoMetadata) { var isAcceptedType = memberInfoMetadata .Type.IsOneOf(typeof(Guid), typeof(int)); if (!isAcceptedType) { return false; } return memberInfoMetadata.Name == "Id" || memberInfoMetadata.GetAttribute<KeyAttribute>().IsNotNull(); }
public bool CanBeTheVersion(MemberInfoMetadata memberInfoMetadata) { var isAcceptedType = memberInfoMetadata .Type.IsOneOf(typeof(DateTime), typeof(byte[])); if (!isAcceptedType) { return false; } return memberInfoMetadata.Name == "Version" || memberInfoMetadata.GetAttribute<TimestampAttribute>().IsNotNull(); }
private void MapVersion <T>(MemberInfoMetadata version, IClassMapper <T> classMapper) where T : class { if (version.IsNull()) { return; } classMapper .Version( version.Name, m => { m.Type(new TimestampType()); m.Generated(VersionGeneration.Never); AccessorHelper.SetAccessor(version, m); }); }
private void MapKey <T>(MemberInfoMetadata key, IClassAttributesMapper <T> classMapper) where T : class { object unsavedKeyValue = 0; if (key.Type == typeof(Guid)) { unsavedKeyValue = Guid.Empty; } classMapper.Id( key.Name, m => { AccessorHelper.SetAccessor(key, m); m.Generator(GetGenerator(key.Type)); m.UnsavedValue(unsavedKeyValue); }); }
public static bool IsRequired(this MemberInfo memberInfo) { var memberMetadata = new MemberInfoMetadata(memberInfo); var isRequired = memberInfo .GetAttribute <RequiredAttribute>() .IsNotNull(); if (memberMetadata.Type.IsNullable() && isRequired) { var message = $"Member '{memberMetadata.Name}' of type '{memberMetadata.Type}' declared in '{memberMetadata.DeclaringType}' cannot " + "have Required attribute because it is a nullable type."; throw new ArgumentException(message); } return(isRequired); }
public bool HasToMap(MemberInfoMetadata memberInfoMetadata) { return !new PrimitiveMemberStrategy().HasToMap(memberInfoMetadata) && !memberInfoMetadata.Type.IsEnumerable(); }
public bool HasToMap(MemberInfoMetadata memberInfoMetadata) { return (!new PrimitiveMemberStrategy().HasToMap(memberInfoMetadata) && !memberInfoMetadata.Type.IsEnumerable()); }