コード例 #1
0
 public bool HasToMap(MemberInfoMetadata memberInfoMetadata)
 {
     return
         (memberInfoMetadata.Type.IsPrimitiveType() ||
          memberInfoMetadata.Type == typeof(byte[]) ||
          memberInfoMetadata.Type.IsNullable());
 }
コード例 #2
0
		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;
		}
コード例 #3
0
        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);
        }
コード例 #4
0
		public bool HasToMap(MemberInfoMetadata memberInfoMetadata)
		{
			return
				memberInfoMetadata.Type.IsPrimitiveType() ||
				memberInfoMetadata.Type == typeof(byte[]) ||
				memberInfoMetadata.Type.IsNullable();
		}
コード例 #5
0
        public bool HasToMap(MemberInfoMetadata memberInfoMetadata)
        {
            if (memberInfoMetadata.Type == typeof(string))
            {
                return
                    (memberInfoMetadata
                     .GetAttribute <StringLengthAttribute>()
                     .IsNotNull());
            }

            return(false);
        }
コード例 #6
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);
            }
        }
コード例 #7
0
		public bool HasToMap(MemberInfoMetadata memberInfoMetadata)
		{
			if (memberInfoMetadata.Type == typeof(string))
			{
				return
					memberInfoMetadata
						.GetAttribute<StringLengthAttribute>()
						.IsNotNull();
			}

			return false;
		}
コード例 #8
0
ファイル: KeyConvention.cs プロジェクト: Eye-Soft/HSDK
        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());
        }
コード例 #9
0
ファイル: VersionConvention.cs プロジェクト: Eye-Soft/HSDK
        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());
        }
コード例 #10
0
ファイル: KeyConvention.cs プロジェクト: matteomigliore/HSDK
		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();
		}
コード例 #11
0
		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();
		}
コード例 #12
0
        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);
            });
        }
コード例 #13
0
        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);
            });
        }
コード例 #14
0
        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);
        }
コード例 #15
0
		public bool HasToMap(MemberInfoMetadata memberInfoMetadata)
		{
			return
				!new PrimitiveMemberStrategy().HasToMap(memberInfoMetadata) &&
				!memberInfoMetadata.Type.IsEnumerable();
		}
コード例 #16
0
 public bool HasToMap(MemberInfoMetadata memberInfoMetadata)
 {
     return
         (!new PrimitiveMemberStrategy().HasToMap(memberInfoMetadata) &&
          !memberInfoMetadata.Type.IsEnumerable());
 }