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;
		}
예제 #2
0
		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);
			}
		}
예제 #3
0
 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;
 }
예제 #4
0
파일: TypeMapper.cs 프로젝트: Eye-Soft/HSDK
 private CollectionMemberInfoMetadata CreateCollectionPropertyInfoMetadata(MemberInfoMetadata memberInfoMetadata)
 {
     return(new CollectionMemberInfoMetadata(memberInfoMetadata));
 }
예제 #5
0
파일: TypeMapper.cs 프로젝트: Eye-Soft/HSDK
 private ReferenceMemberInfoMetadata CreateReferencePropertyInfoMetadata(MemberInfoMetadata memberInfoMetadata)
 {
     return(new ReferenceMemberInfoMetadata(memberInfoMetadata));
 }
예제 #6
0
파일: TypeMapper.cs 프로젝트: Eye-Soft/HSDK
 private PrimitiveMemberInfoMetadata CreatePrimitivePropertyInfoMetadata(MemberInfoMetadata memberInfoMetadata)
 {
     return(new PrimitiveMemberInfoMetadata(memberInfoMetadata));
 }
예제 #7
0
파일: TypeMapper.cs 프로젝트: Eye-Soft/HSDK
 private bool CustomStrategy(IMemberStrategy memberStrategy, MemberInfoMetadata member)
 {
     return
         ((memberStrategy == null) || memberStrategy.HasToMap(member));
 }