Ejemplo n.º 1
0
 public void Apply(IPropertyInstance instance)
 {
     if (typeof(SiteEntity).IsAssignableFrom(instance.EntityType))
     {
         if (instance.Property.PropertyType == typeof(DateTime))
         {
             instance.CustomType <DateTimeData>();
         }
         else if (instance.Property.PropertyType == typeof(DateTime?))
         {
             instance.CustomType <NullableDateTimeData>();
         }
     }
     else if (typeof(SystemEntity).IsAssignableFrom(instance.EntityType))
     {
         if (instance.Property.PropertyType == typeof(DateTime))
         {
             instance.CustomType <LocalDateTimeData>();
         }
         else if (instance.Property.PropertyType == typeof(DateTime?))
         {
             instance.CustomType <LocalNullableDateTimeData>();
         }
     }
 }
Ejemplo n.º 2
0
        public void Apply(IPropertyInstance instance)
        {
            if (instance.Type.IsEnum == false)
                return;

            if (EnumType == EnumType.Integer)
                instance.CustomType<int>();
            else
                instance.CustomType<string>();
        }
Ejemplo n.º 3
0
        public void Apply(IPropertyInstance instance)
        {
            var attr = instance.Property.MemberInfo.GetCustomAttribute <EnumStringAttribute>();

            if (attr == null)
            {
                instance.CustomType(instance.Property.PropertyType);
            }
            else
            {
                var customType = typeof(EnumStringType <>).MakeGenericType(instance.Property.PropertyType);
                instance.CustomType(customType);
            }
        }
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType.Equals(typeof(IGeometry)))
     {
         instance.CustomType <SqLiteGeometryType>();
     }
 }
Ejemplo n.º 5
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType == typeof(string))
     {
         instance.CustomType("AnsiString");
     }
 }
Ejemplo n.º 6
0
 /// <inheritdoc/>
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Type.Name == "DateTime" && instance.Property.Name.ToLower().Contains("utc"))
     {
         instance.CustomType <UtcDateTimeType>();
     }
 }
Ejemplo n.º 7
0
 public void Apply(IPropertyInstance instance)
 {
     if (typeof(Uri).IsAssignableFrom(instance.Property.PropertyType))
     {
         instance.CustomType <UriType>();
     }
 }
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Type == typeof(TheSpecialEnum))
     {
         instance.CustomType <SpecialEnumUserType>();
     }
 }
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType == typeof(TimeSpan))
     {
         instance.CustomType("TimeAsTimeSpan");
     }
 }
 public void Apply(IPropertyInstance instance)
 {
     if (new[] { typeof(DateTimeOffset), typeof(DateTimeOffset?) }.Contains(instance.Property.PropertyType))
     {
         instance.CustomType("timestamptz");
     }
 }
Ejemplo n.º 11
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType.Equals(typeof(IGeometry)))
     {
         instance.CustomType(typeof(MsSqlGeometryHandler));
     }
 }
Ejemplo n.º 12
0
 public void Apply(IPropertyInstance instance)
 {
     if (new[] { typeof(DateTime), typeof(DateTime?) }.Contains(instance.Property.PropertyType))
     {
         instance.CustomType("UtcDateTime");
     }
 }
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType.Equals(typeof(IGeometry)))
     {
         instance.CustomType<SqLiteGeometryType>();
     }
 }
Ejemplo n.º 14
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Type.Name == "Date")
     {
         instance.CustomType <UtcDateTimeType>();
     }
 }
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Type == typeof(Type))
     {
         instance.CustomType <VersionAgnosticType>();
     }
 }
 public override void Apply(IPropertyInstance instance)
 {
     // Have to set CustomType to be able to read/write rows using NHibernate
     instance.CustomType <PostGisGeometryType>();
     // Have to set CustomSqlType to generate correct SQL schema
     instance.CustomSqlType("geometry(Polygon)");
 }
Ejemplo n.º 17
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Type.IsEnum)
     {
         instance.CustomType <SpecialEnumUserType>();
     }
 }
Ejemplo n.º 18
0
        public void Apply(IPropertyInstance instance)
        {
            if (new[] { typeof(TimeSpan), typeof(TimeSpan?) }.Contains(instance.Property.PropertyType))
            {
                instance.CustomType("TimeAsTimeSpan");
            }

            /*
             * if(new []{typeof(DateTime), typeof(DateTime?)}.Contains(instance.Property.PropertyType))
             *  instance.CustomType("datetime2");
             */

            if (new[] { typeof(DateTimeOffset), typeof(DateTimeOffset?) }.Contains(instance.Property.PropertyType))
            {
                instance.CustomType("datetimeoffset");
            }
        }
Ejemplo n.º 19
0
 public void Apply(IPropertyInstance instance)
 {
     if (typeof(IGeometry).IsAssignableFrom(instance.Property.PropertyType))
     {
         instance.CustomType(typeof(GeographyType));
         instance.CustomSqlType("GEOGRAPHY");
     }
 }
Ejemplo n.º 20
0
 /// <inheritdoc/>
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.Name.ToLower() == "createdatutc" || instance.Property.Name.ToLower() == "updatedatutc")
     {
         instance.CustomType <UtcDateTimeType>();
         instance.Generated.Always();
     }
 }
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType.Equals(typeof(IGeometry)))
     {
         instance.CustomType<GeometryType>();
         instance.CustomSqlType("Geography");
     }
 }
Ejemplo n.º 22
0
        public void Apply(IPropertyInstance instance)
        {
            var propertyType = instance.Type.GetUnderlyingSystemType();

            var customType = typeof(NHStrongTypeIdUserType <>).MakeGenericType(propertyType);

            instance.CustomType(customType);
        }
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType.Equals(typeof(IGeometry)))
     {
         instance.CustomType <GeometryType>();
         instance.CustomSqlType("Geography");
     }
 }
 public void Apply(IPropertyInstance instance)
 {
     if (typeof(IGeometry).IsAssignableFrom(instance.Property.PropertyType))
     {
         instance.CustomType(typeof(GeographyType));
         instance.CustomSqlType("GEOGRAPHY");
     }
 }
Ejemplo n.º 25
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType == typeof(NpgsqlRange <LocalDate>))
     {
         instance.CustomType <RangeDateType>();
         instance.CustomSqlType("daterange");
     }
 }
        /// <summary>
        /// The convention that is applied to a <see cref = "IPropertyInstance" /> when the criteria from the Accept method is meet.
        /// </summary>
        /// <param name="instance">An <see cref = "IPropertyInstance" /> to apply the convention to.</param>
        public void Apply(IPropertyInstance instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            instance.CustomType<DateTimeOffsetSplitType>();
        }
Ejemplo n.º 27
0
        public void Apply(IPropertyInstance instance)
        {
            var type = instance.Property.PropertyType;

            if (type == typeof(XElement))
            {
                instance.CustomType <XElementUserType>();
            }
        }
Ejemplo n.º 28
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType == typeof(LocalTime) ||
         instance.Property.PropertyType == typeof(LocalTime?))
     {
         instance.CustomType <LocalTimeType>();
     }
     else if (instance.Property.PropertyType == typeof(LocalDate) ||
              instance.Property.PropertyType == typeof(LocalDate?))
     {
         instance.CustomType <LocalDateType>();
     }
     else if (instance.Property.PropertyType == typeof(Instant) ||
              instance.Property.PropertyType == typeof(Instant?))
     {
         instance.CustomType <InstantType>();
     }
 }
Ejemplo n.º 29
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.ToString().Contains("String"))
     {
         instance.CustomType("StringClob");
         instance.CustomSqlType("NTEXT");
         //instance.Length(4001);
     }
 }
Ejemplo n.º 30
0
        public void Apply(IPropertyInstance instance)
        {
            if (typeof(SiteEntity).IsAssignableFrom(instance.EntityType))
            {
                if (instance.Property.PropertyType == typeof(DateTime))
                    instance.CustomType<DateTimeData>();
                else if (instance.Property.PropertyType == typeof(DateTime?))
                    instance.CustomType<NullableDateTimeData>();
            }
            else if (typeof(SystemEntity).IsAssignableFrom(instance.EntityType))
            {
                if (instance.Property.PropertyType == typeof(DateTime))
                    instance.CustomType<LocalDateTimeData>();
                else if (instance.Property.PropertyType == typeof(DateTime?))
                    instance.CustomType<LocalNullableDateTimeData>();

            }
        }
Ejemplo n.º 31
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Type.Name == "Date")
     {
         //or
         //if (instance.Type.GetUnderlyingSystemType() == typeof(Date))
         instance.CustomType <DateTranslator>();
     }
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Applies the specified instance.
        /// </summary>
        /// <param name="instance">The instance.</param>
        public void Apply(IPropertyInstance instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            instance.CustomType(instance.Property.PropertyType);
        }
Ejemplo n.º 33
0
        public void Apply(IPropertyInstance instance)
        {
            instance.CustomType <BinaryBlobType>();
            instance.Nullable();

            // Length is set because the NHibernate BinaryBlobType only specifies the SQL type as "binary", defaulting to a max length of 8000
            instance.Length(int.MaxValue);

            lazyLoadIfSpecified(instance);
        }
Ejemplo n.º 34
0
        public void Apply(IPropertyInstance instance)
        {
            var type = instance.Property.PropertyType;

            if (type == typeof(DateTime) || type == typeof(DateTime?))
            {
                instance.CustomType("timestamp");
                instance.CustomSqlType("datetime2");
            }
        }
Ejemplo n.º 35
0
        public void Apply(IPropertyInstance instance)
        {
            if (!instance.Property.PropertyType.IsSubclassOf(typeof(Geometry)))
            {
                return;
            }

            instance.CustomType <Wgs84GeometryType>();
            instance.CustomSqlType("geometry");
        }
Ejemplo n.º 36
0
        public void Apply(IPropertyInstance instance)
        {
            var propertyType     = instance.Type.GetUnderlyingSystemType();
            var identityUserType = this.GetUserType(propertyType);

            if (identityUserType == null)
            {
                return;
            }

            instance.CustomType(identityUserType);
        }
Ejemplo n.º 37
0
        public void Apply(IPropertyInstance instance)
        {
            if (instance.Property.PropertyType == typeof(byte[]))
            {
                instance.CustomType("BinaryBlob");
                instance.Length(1048576);
            }
            else
            {
                instance.CustomType(instance.Property.PropertyType);

                if (instance.Property.PropertyType.IsEnum)
                {
                    instance.Not.Nullable();
                }

                if (instance.Property.Name.Equals("Deleted"))
                {
                    instance.Not.Nullable();
                }
            }
        }
Ejemplo n.º 38
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType == typeof(string))
     {
         instance.CustomType("AnsiString");
         instance.Length(500);
     }
     else if (instance.Property.PropertyType == typeof(decimal))
     {
         instance.Precision(18);
         instance.Scale(2);
     }
 }
Ejemplo n.º 39
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType != typeof(string))
         return;
     var memberInfo = instance.Property.MemberInfo;
     var stringLengthAttribute = memberInfo.GetCustomAttribute<StringLengthAttribute>();
     var isDbLengthAttribute = memberInfo.GetCustomAttribute<IsDBLengthAttribute>();
     if (stringLengthAttribute != null && isDbLengthAttribute != null)
     {
         instance.Length(stringLengthAttribute.MaximumLength);
     }
     else
     {
         instance.CustomType<VarcharMax>();
         instance.Length(4001);
     }
 }
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType<int>();
     instance.Not.Nullable();
 }
Ejemplo n.º 41
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType == typeof(string))
         instance.CustomType("AnsiString");
 }
Ejemplo n.º 42
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Type.IsEnum)
         instance.CustomType<int>();
 }
 public void Apply(IPropertyInstance instance) {
     instance.CustomType<UtcDateTimeType>();
 }
Ejemplo n.º 44
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType<UserType>();
 }
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType("Ticks");
 }
Ejemplo n.º 46
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType(instance.Property.PropertyType);
     instance.Not.Nullable();
 }
Ejemplo n.º 47
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType == typeof(TimeSpan))
         instance.CustomType("TimeAsTimeSpan");
 }
        public void Apply(IPropertyInstance instance)
        {
            var closedType = openType.MakeGenericType(instance.Property.PropertyType);

            instance.CustomType(closedType);
        }
Ejemplo n.º 49
0
 public void Apply(IPropertyInstance instance)
 {
     instance.Length(Enum.GetNames(instance.Property.PropertyType).Max(name => name.Length));
     instance.CustomType(typeof(string));
 }
		public void Apply(IPropertyInstance instance)
		{
			instance.CustomType(typeof(EnumerableOfStringType));
		}
Ejemplo n.º 51
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType<TimestampType>();
 }
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType<CultureInfoType>();
 }
Ejemplo n.º 53
0
 public void Apply(IPropertyInstance target)
 {
     target.CustomType(target.Property.PropertyType);
 }
Ejemplo n.º 54
0
		public void Apply(IPropertyInstance instance)
		{
			instance.CustomType(instance.Property.PropertyType);
			// Enumerations can't be null
			instance.Not.Nullable();
		}
Ejemplo n.º 55
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType(instance.Property.PropertyType);
 }
Ejemplo n.º 56
0
		public void Apply(IPropertyInstance instance)
		{
			instance.CustomType(typeof(NullableTimeType));
		}
Ejemplo n.º 57
0
		public void Apply(IPropertyInstance instance)
		{
			instance.CustomType(typeof(ByteType));
		}
Ejemplo n.º 58
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType(instance.Property.PropertyType);
     Debug.WriteLine("-----IUserTypeConvention----"+instance.EntityType+" " + instance.Property.PropertyType);
 }