diff --git a/src/NHibernate/Async/Type/Int16Type.cs b/src/NHibernate/Async/Type/Int16Type.cs index 804d767eafd..598f83c5aa5 100644 --- a/src/NHibernate/Async/Type/Int16Type.cs +++ b/src/NHibernate/Async/Type/Int16Type.cs @@ -24,8 +24,6 @@ namespace NHibernate.Type public partial class Int16Type : PrimitiveType, IDiscriminatorType, IVersionType { - #region IVersionType Members - public virtual Task NextAsync(object current, ISessionImplementor session, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) @@ -57,7 +55,5 @@ public virtual Task SeedAsync(ISessionImplementor session, CancellationT return Task.FromException(ex); } } - - #endregion } } diff --git a/src/NHibernate/Type/AbstractCharType.cs b/src/NHibernate/Type/AbstractCharType.cs index f813c85fb60..ba2ad5bb761 100644 --- a/src/NHibernate/Type/AbstractCharType.cs +++ b/src/NHibernate/Type/AbstractCharType.cs @@ -11,14 +11,13 @@ namespace NHibernate.Type [Serializable] public abstract class AbstractCharType : PrimitiveType, IDiscriminatorType { - public AbstractCharType(SqlType sqlType) - : base(sqlType) {} - - public override object DefaultValue + /// + public AbstractCharType(SqlType sqlType) : base(sqlType) { - get { throw new NotSupportedException("not a valid id type"); } } + public override object DefaultValue => throw new NotSupportedException("not a valid id type"); + public override object Get(DbDataReader rs, int index, ISessionImplementor session) { string dbValue = Convert.ToString(rs[index]); @@ -30,15 +29,9 @@ public override object Get(DbDataReader rs, int index, ISessionImplementor sessi return '\0'; // This line should never be executed } - public override System.Type PrimitiveClass - { - get { return typeof(char); } - } + public override System.Type PrimitiveClass => typeof(char); - public override System.Type ReturnedClass - { - get { return typeof(char); } - } + public override System.Type ReturnedClass => typeof(char); public override void Set(DbCommand cmd, object value, int index, ISessionImplementor session) { diff --git a/src/NHibernate/Type/AbstractDateTimeType.cs b/src/NHibernate/Type/AbstractDateTimeType.cs index b5b5b5c65c3..9deb2273d3e 100644 --- a/src/NHibernate/Type/AbstractDateTimeType.cs +++ b/src/NHibernate/Type/AbstractDateTimeType.cs @@ -14,7 +14,7 @@ namespace NHibernate.Type [Serializable] public abstract partial class AbstractDateTimeType : PrimitiveType, IIdentifierType, ILiteralType, IVersionType { - private static readonly DateTime BaseDateValue = DateTime.MinValue; + private static readonly object BaseDateValue = DateTime.MinValue; /// /// Returns the for the type. @@ -31,17 +31,12 @@ public abstract partial class AbstractDateTimeType : PrimitiveType, IIdentifierT /// otherwise. protected virtual DateTime Now => Kind == DateTimeKind.Utc ? DateTime.UtcNow : DateTime.Now; - /// - /// Default constructor. - /// - protected AbstractDateTimeType() : base(SqlTypeFactory.DateTime) + /// + protected AbstractDateTimeType() : this(SqlTypeFactory.DateTime) { } - /// - /// Constructor for overriding the default . - /// - /// The to use. + /// protected AbstractDateTimeType(SqlType sqlTypeDateTime) : base(sqlTypeDateTime) { } diff --git a/src/NHibernate/Type/ByteType.cs b/src/NHibernate/Type/ByteType.cs index 4a1e5fa7928..f52071890ff 100644 --- a/src/NHibernate/Type/ByteType.cs +++ b/src/NHibernate/Type/ByteType.cs @@ -15,10 +15,10 @@ namespace NHibernate.Type [Serializable] public partial class ByteType : PrimitiveType, IDiscriminatorType, IVersionType { - private static readonly byte ZERO = 0; + private static readonly object ZeroObject = (byte) 0; - public ByteType() - : base(SqlTypeFactory.Byte) + /// + public ByteType() : base(SqlTypeFactory.Byte) { } @@ -32,15 +32,9 @@ public override object Get(DbDataReader rs, int index, ISessionImplementor sessi }; } - public override System.Type ReturnedClass - { - get { return typeof(byte); } - } + public override System.Type ReturnedClass => typeof(byte); - public override System.Type PrimitiveClass - { - get { return typeof(byte); } - } + public override System.Type PrimitiveClass => typeof(byte); public override void Set(DbCommand cmd, object value, int index, ISessionImplementor session) { @@ -48,10 +42,7 @@ public override void Set(DbCommand cmd, object value, int index, ISessionImpleme dp.Value = dp.DbType == DbType.Int16 ? Convert.ToInt16(value) : Convert.ToByte(value); } - public override string Name - { - get { return "Byte"; } - } + public override string Name => "Byte"; public override string ObjectToSQLString(object value, Dialect.Dialect dialect) { @@ -84,17 +75,11 @@ public virtual object Next(object current, ISessionImplementor session) public virtual object Seed(ISessionImplementor session) { - return ZERO; + return ZeroObject; } - public IComparer Comparator - { - get { return Comparer.DefaultInvariant; } - } + public IComparer Comparator => Comparer.DefaultInvariant; - public override object DefaultValue - { - get { return ZERO; } - } + public override object DefaultValue => ZeroObject; } } diff --git a/src/NHibernate/Type/DateTimeOffSetType.cs b/src/NHibernate/Type/DateTimeOffSetType.cs index de9e8b2216c..10bfa4f6804 100644 --- a/src/NHibernate/Type/DateTimeOffSetType.cs +++ b/src/NHibernate/Type/DateTimeOffSetType.cs @@ -14,47 +14,26 @@ namespace NHibernate.Type [Serializable] public partial class DateTimeOffsetType : PrimitiveType, IIdentifierType, ILiteralType, IVersionType { - static readonly DateTimeOffset BaseDateValue = DateTimeOffset.MinValue; + private static readonly object BaseDateValue = DateTimeOffset.MinValue; - /// - /// Default constructor. - /// public DateTimeOffsetType() : base(SqlTypeFactory.DateTimeOffSet) { } - /// - /// Constructor for specifying a datetimeoffset with a scale. Use . - /// - /// The sql type to use for the type. + /// public DateTimeOffsetType(DateTimeOffsetSqlType sqlType) : base(sqlType) { } - public override string Name - { - get { return "DateTimeOffset"; } - } + public override string Name => "DateTimeOffset"; - public override System.Type ReturnedClass - { - get { return typeof (DateTimeOffset); } - } + public override System.Type ReturnedClass => typeof (DateTimeOffset); - public override System.Type PrimitiveClass - { - get { return typeof (DateTimeOffset); } - } + public override System.Type PrimitiveClass => typeof (DateTimeOffset); - public override object DefaultValue - { - get { return BaseDateValue; } - } + public override object DefaultValue => BaseDateValue; - public IComparer Comparator - { - get { return Comparer.Default; } - } + public IComparer Comparator => Comparer.Default; public override void Set(DbCommand st, object value, int index, ISessionImplementor session) { diff --git a/src/NHibernate/Type/DateType.cs b/src/NHibernate/Type/DateType.cs index 76d3fbb99e9..7bf772c9e95 100644 --- a/src/NHibernate/Type/DateType.cs +++ b/src/NHibernate/Type/DateType.cs @@ -21,11 +21,12 @@ public class DateType : AbstractDateTimeType, IParameterizedType // Since v5.0 [Obsolete("Use DateTime.MinValue.")] public static readonly DateTime BaseDateValue = DateTime.MinValue; - private DateTime customBaseDate = _baseDateValue; private static readonly DateTime _baseDateValue = DateTime.MinValue; - /// Default constructor + private object customBaseDate = _baseDateValue; + + /// public DateType() : base(SqlTypeFactory.Date) { } diff --git a/src/NHibernate/Type/DecimalType.cs b/src/NHibernate/Type/DecimalType.cs index 06fb8d449d9..e2398ec4ce6 100644 --- a/src/NHibernate/Type/DecimalType.cs +++ b/src/NHibernate/Type/DecimalType.cs @@ -13,11 +13,15 @@ namespace NHibernate.Type [Serializable] public class DecimalType : PrimitiveType, IIdentifierType { + private static readonly object ZeroObject = 0m; + + /// public DecimalType() : this(SqlTypeFactory.Decimal) { } + /// public DecimalType(SqlType sqlType) : base(sqlType) { } @@ -27,30 +31,18 @@ public override object Get(DbDataReader rs, int index, ISessionImplementor sessi return Convert.ToDecimal(rs[index]); } - public override System.Type ReturnedClass - { - get { return typeof(Decimal); } - } + public override System.Type ReturnedClass => typeof(Decimal); public override void Set(DbCommand st, object value, int index, ISessionImplementor session) { st.Parameters[index].Value = Convert.ToDecimal(value); } - public override string Name - { - get { return "Decimal"; } - } + public override string Name => "Decimal"; - public override System.Type PrimitiveClass - { - get { return typeof (Decimal); } - } + public override System.Type PrimitiveClass => typeof (Decimal); - public override object DefaultValue - { - get { return 0m; } - } + public override object DefaultValue => ZeroObject; // Since 5.2 [Obsolete("This method has no more usages and will be removed in a future version.")] diff --git a/src/NHibernate/Type/DoubleType.cs b/src/NHibernate/Type/DoubleType.cs index fb5c159c9aa..45b5713f525 100644 --- a/src/NHibernate/Type/DoubleType.cs +++ b/src/NHibernate/Type/DoubleType.cs @@ -14,12 +14,17 @@ namespace NHibernate.Type [Serializable] public class DoubleType : PrimitiveType { - /// + private static readonly object ZeroObject = 0D; + + /// public DoubleType() : base(SqlTypeFactory.Double) { } - public DoubleType(SqlType sqlType) : base(sqlType) {} + /// + public DoubleType(SqlType sqlType) : base(sqlType) + { + } public override object Get(DbDataReader rs, int index, ISessionImplementor session) { @@ -31,10 +36,7 @@ public override object Get(DbDataReader rs, int index, ISessionImplementor sessi } /// - public override System.Type ReturnedClass - { - get { return typeof(double); } - } + public override System.Type ReturnedClass => typeof(double); public override void Set(DbCommand st, object value, int index, ISessionImplementor session) { @@ -42,10 +44,7 @@ public override void Set(DbCommand st, object value, int index, ISessionImplemen } /// - public override string Name - { - get { return "Double"; } - } + public override string Name => "Double"; // Since 5.2 [Obsolete("This method has no more usages and will be removed in a future version.")] @@ -54,15 +53,9 @@ public override object FromStringValue(string xml) return double.Parse(xml); } - public override System.Type PrimitiveClass - { - get { return typeof(double); } - } + public override System.Type PrimitiveClass => typeof(double); - public override object DefaultValue - { - get { return 0D; } - } + public override object DefaultValue => ZeroObject; public override string ObjectToSQLString(object value, Dialect.Dialect dialect) { diff --git a/src/NHibernate/Type/GuidType.cs b/src/NHibernate/Type/GuidType.cs index 938a5436af4..2dc627d5d09 100644 --- a/src/NHibernate/Type/GuidType.cs +++ b/src/NHibernate/Type/GuidType.cs @@ -13,7 +13,9 @@ namespace NHibernate.Type [Serializable] public class GuidType : PrimitiveType, IDiscriminatorType { - /// + private static readonly object EmptyObject = Guid.Empty; + + /// public GuidType() : base(SqlTypeFactory.Guid) { } @@ -34,10 +36,7 @@ public override object Get(DbDataReader rs, int index, ISessionImplementor sessi } /// - public override System.Type ReturnedClass - { - get { return typeof(Guid); } - } + public override System.Type ReturnedClass => typeof(Guid); public override void Set(DbCommand cmd, object value, int index, ISessionImplementor session) { @@ -47,10 +46,7 @@ public override void Set(DbCommand cmd, object value, int index, ISessionImpleme } /// - public override string Name - { - get { return "Guid"; } - } + public override string Name => "Guid"; // Since 5.2 [Obsolete("This method has no more usages and will be removed in a future version.")] @@ -71,15 +67,9 @@ public object StringToObject(string xml) #pragma warning restore 618 } - public override System.Type PrimitiveClass - { - get { return typeof(Guid); } - } + public override System.Type PrimitiveClass => typeof(Guid); - public override object DefaultValue - { - get { return Guid.Empty; } - } + public override object DefaultValue => EmptyObject; public override string ObjectToSQLString(object value, Dialect.Dialect dialect) { diff --git a/src/NHibernate/Type/Int16Type.cs b/src/NHibernate/Type/Int16Type.cs index 20d2975f0d8..cfd21908465 100644 --- a/src/NHibernate/Type/Int16Type.cs +++ b/src/NHibernate/Type/Int16Type.cs @@ -16,18 +16,16 @@ namespace NHibernate.Type [Serializable] public partial class Int16Type : PrimitiveType, IDiscriminatorType, IVersionType { - /// + private static readonly object ZeroObject = (short) 0; + + /// public Int16Type() : base(SqlTypeFactory.Int16) { } /// - public override string Name - { - get { return "Int16"; } - } + public override string Name => "Int16"; - private static readonly Int16 ZERO = 0; public override object Get(DbDataReader rs, int index, ISessionImplementor session) { try @@ -44,10 +42,7 @@ public override object Get(DbDataReader rs, int index, ISessionImplementor sessi } } - public override System.Type ReturnedClass - { - get { return typeof(Int16); } - } + public override System.Type ReturnedClass => typeof(Int16); public override void Set(DbCommand rs, object value, int index, ISessionImplementor session) { @@ -76,8 +71,6 @@ public override object FromStringValue(string xml) return Int16.Parse(xml); } - #region IVersionType Members - public virtual object Next(object current, ISessionImplementor session) { return (Int16)((Int16)current + 1); @@ -88,22 +81,11 @@ public virtual object Seed(ISessionImplementor session) return (Int16)1; } - public IComparer Comparator - { - get { return Comparer.Default; } - } + public IComparer Comparator => Comparer.Default; - #endregion + public override System.Type PrimitiveClass => typeof (Int16); - public override System.Type PrimitiveClass - { - get { return typeof (Int16); } - } - - public override object DefaultValue - { - get { return ZERO; } - } + public override object DefaultValue => ZeroObject; public override string ObjectToSQLString(object value, Dialect.Dialect dialect) { diff --git a/src/NHibernate/Type/Int32Type.cs b/src/NHibernate/Type/Int32Type.cs index 21c568ffb3a..f19fb1148fd 100644 --- a/src/NHibernate/Type/Int32Type.cs +++ b/src/NHibernate/Type/Int32Type.cs @@ -16,18 +16,15 @@ namespace NHibernate.Type [Serializable] public partial class Int32Type : PrimitiveType, IDiscriminatorType, IVersionType { - /// + private static readonly object ZeroObject = 0; + + /// public Int32Type() : base(SqlTypeFactory.Int32) { } /// - public override string Name - { - get { return "Int32"; } - } - - private static readonly Int32 ZERO = 0; + public override string Name => "Int32"; public override object Get(DbDataReader rs, int index, ISessionImplementor session) { @@ -45,10 +42,7 @@ public override object Get(DbDataReader rs, int index, ISessionImplementor sessi } } - public override System.Type ReturnedClass - { - get { return typeof(Int32); } - } + public override System.Type ReturnedClass => typeof(Int32); public override void Set(DbCommand rs, object value, int index, ISessionImplementor session) { @@ -89,22 +83,13 @@ public virtual object Seed(ISessionImplementor session) return 1; } - public IComparer Comparator - { - get { return Comparer.Default; } - } + public IComparer Comparator => Comparer.Default; #endregion - public override System.Type PrimitiveClass - { - get { return typeof(Int32); } - } + public override System.Type PrimitiveClass => typeof(Int32); - public override object DefaultValue - { - get { return ZERO; } - } + public override object DefaultValue => ZeroObject; public override string ObjectToSQLString(object value, Dialect.Dialect dialect) { diff --git a/src/NHibernate/Type/Int64Type.cs b/src/NHibernate/Type/Int64Type.cs index 42899a25794..b86cb619443 100644 --- a/src/NHibernate/Type/Int64Type.cs +++ b/src/NHibernate/Type/Int64Type.cs @@ -16,18 +16,16 @@ namespace NHibernate.Type [Serializable] public partial class Int64Type : PrimitiveType, IDiscriminatorType, IVersionType { - /// + private static readonly object ZeroObject = 0L; + + /// public Int64Type() : base(SqlTypeFactory.Int64) { } /// - public override string Name - { - get { return "Int64"; } - } + public override string Name => "Int64"; - private static readonly Int64 ZERO = 0; public override object Get(DbDataReader rs, int index, ISessionImplementor session) { try @@ -44,10 +42,7 @@ public override object Get(DbDataReader rs, int index, ISessionImplementor sessi } } - public override System.Type ReturnedClass - { - get { return typeof(Int64); } - } + public override System.Type ReturnedClass => typeof(Int64); public override void Set(DbCommand rs, object value, int index, ISessionImplementor session) { @@ -88,22 +83,13 @@ public virtual object Seed(ISessionImplementor session) return 1L; } - public IComparer Comparator - { - get { return Comparer.Default; } - } + public IComparer Comparator => Comparer.Default; #endregion - public override System.Type PrimitiveClass - { - get { return typeof(Int64); } - } + public override System.Type PrimitiveClass => typeof(Int64); - public override object DefaultValue - { - get { return ZERO; } - } + public override object DefaultValue => ZeroObject; public override string ObjectToSQLString(object value, Dialect.Dialect dialect) { diff --git a/src/NHibernate/Type/PrimitiveType.cs b/src/NHibernate/Type/PrimitiveType.cs index 7b452db3481..2956f394eb5 100644 --- a/src/NHibernate/Type/PrimitiveType.cs +++ b/src/NHibernate/Type/PrimitiveType.cs @@ -10,19 +10,15 @@ namespace NHibernate.Type [Serializable] public abstract class PrimitiveType : ImmutableType, ILiteralType { - /// - /// Initialize a new instance of the PrimitiveType class using a . - /// - /// The underlying . - protected PrimitiveType(SqlType sqlType) - : base(sqlType) {} + /// + protected PrimitiveType(SqlType sqlType) : base(sqlType) + { + } public abstract System.Type PrimitiveClass { get; } public abstract object DefaultValue { get; } - #region ILiteralType Members - /// /// When implemented by a class, return a representation /// of the value, suitable for embedding in an SQL statement @@ -32,8 +28,6 @@ protected PrimitiveType(SqlType sqlType) /// A string that containts a well formed SQL Statement. public abstract string ObjectToSQLString(object value, Dialect.Dialect dialect); - #endregion - /// public override string ToLoggableString(object value, ISessionFactoryImplementor factory) { diff --git a/src/NHibernate/Type/SByteType.cs b/src/NHibernate/Type/SByteType.cs index 304a034958c..513cacb6e70 100644 --- a/src/NHibernate/Type/SByteType.cs +++ b/src/NHibernate/Type/SByteType.cs @@ -16,18 +16,16 @@ namespace NHibernate.Type [Serializable] public class SByteType : PrimitiveType, IDiscriminatorType { - /// + private static readonly object ZeroObject = (sbyte) 0; + + /// public SByteType() : base(SqlTypeFactory.SByte) { } /// - public override string Name - { - get { return "SByte"; } - } + public override string Name => "SByte"; - private static readonly SByte ZERO = 0; public override object Get(DbDataReader rs, int index, ISessionImplementor session) { try @@ -44,10 +42,7 @@ public override object Get(DbDataReader rs, int index, ISessionImplementor sessi } } - public override System.Type ReturnedClass - { - get { return typeof(SByte); } - } + public override System.Type ReturnedClass => typeof(SByte); public override void Set(DbCommand rs, object value, int index, ISessionImplementor session) { @@ -72,8 +67,6 @@ public override object FromStringValue(string xml) return SByte.Parse(xml); } - #region IVersionType Members - // Since 5.2 [Obsolete("This member has no more usage and will be removed in a future version.")] public virtual object Next(object current, ISessionImplementor session) @@ -90,22 +83,11 @@ public virtual object Seed(ISessionImplementor session) // Since 5.2 [Obsolete("This member has no more usage and will be removed in a future version.")] - public IComparer Comparator - { - get { return Comparer.Default; } - } + public IComparer Comparator => Comparer.Default; - #endregion + public override System.Type PrimitiveClass => typeof(SByte); - public override System.Type PrimitiveClass - { - get { return typeof(SByte); } - } - - public override object DefaultValue - { - get { return ZERO; } - } + public override object DefaultValue => ZeroObject; public override string ObjectToSQLString(object value, Dialect.Dialect dialect) { diff --git a/src/NHibernate/Type/SingleType.cs b/src/NHibernate/Type/SingleType.cs index 31166b2b925..a5d56ce9ade 100644 --- a/src/NHibernate/Type/SingleType.cs +++ b/src/NHibernate/Type/SingleType.cs @@ -18,20 +18,20 @@ namespace NHibernate.Type [Serializable] public class SingleType : PrimitiveType { - /// - public SingleType() : base(SqlTypeFactory.Single) + private static readonly object ZeroObject = 0F; + + public SingleType() : this(SqlTypeFactory.Single) { } - public SingleType(SqlType sqlType) : base(sqlType) {} - - /// - public override string Name + /// + public SingleType(SqlType sqlType) : base(sqlType) { - get { return "Single"; } } - private static readonly Single ZERO = 0; + /// + public override string Name => "Single"; + public override object Get(DbDataReader rs, int index, ISessionImplementor session) { try @@ -48,10 +48,7 @@ public override object Get(DbDataReader rs, int index, ISessionImplementor sessi } } - public override System.Type ReturnedClass - { - get { return typeof(Single); } - } + public override System.Type ReturnedClass => typeof(Single); public override void Set(DbCommand rs, object value, int index, ISessionImplementor session) { @@ -72,15 +69,9 @@ public override object FromStringValue(string xml) return Single.Parse(xml); } - public override System.Type PrimitiveClass - { - get { return typeof(Single); } - } + public override System.Type PrimitiveClass => typeof(Single); - public override object DefaultValue - { - get { return ZERO; } - } + public override object DefaultValue => ZeroObject; public override string ObjectToSQLString(object value, Dialect.Dialect dialect) { diff --git a/src/NHibernate/Type/TimeAsTimeSpanType.cs b/src/NHibernate/Type/TimeAsTimeSpanType.cs index 993262af202..f5218c0775c 100644 --- a/src/NHibernate/Type/TimeAsTimeSpanType.cs +++ b/src/NHibernate/Type/TimeAsTimeSpanType.cs @@ -16,27 +16,20 @@ namespace NHibernate.Type [Serializable] public partial class TimeAsTimeSpanType : PrimitiveType, IVersionType { + private static readonly object ZeroObject = TimeSpan.Zero; private static readonly DateTime BaseDateValue = new DateTime(1753, 01, 01); - /// - /// Default constructor. - /// + /// public TimeAsTimeSpanType() : base(SqlTypeFactory.Time) { } - /// - /// Constructor for specifying a time with a scale. Use . - /// - /// The sql type to use for the type. + /// public TimeAsTimeSpanType(TimeSqlType sqlType) : base(sqlType) { } - public override string Name - { - get { return "TimeAsTimeSpan"; } - } + public override string Name => "TimeAsTimeSpan"; public override object Get(DbDataReader rs, int index, ISessionImplementor session) { @@ -65,10 +58,7 @@ public override void Set(DbCommand st, object value, int index, ISessionImplemen st.Parameters[index].Value = BaseDateValue.AddTicks(((TimeSpan)value).Ticks); } - public override System.Type ReturnedClass - { - get { return typeof(TimeSpan); } - } + public override System.Type ReturnedClass => typeof(TimeSpan); /// public override string ToLoggableString(object value, ISessionFactoryImplementor factory) @@ -106,10 +96,7 @@ public object StringToObject(string xml) return TimeSpan.Parse(xml); } - public IComparer Comparator - { - get { return Comparer.Default; } - } + public IComparer Comparator => Comparer.Default; #endregion @@ -124,15 +111,9 @@ public override object FromStringValue(string xml) return TimeSpan.Parse(xml); } - public override System.Type PrimitiveClass - { - get { return typeof(TimeSpan); } - } + public override System.Type PrimitiveClass => typeof(TimeSpan); - public override object DefaultValue - { - get { return TimeSpan.Zero; } - } + public override object DefaultValue => ZeroObject; public override string ObjectToSQLString(object value, Dialect.Dialect dialect) { diff --git a/src/NHibernate/Type/TimeSpanType.cs b/src/NHibernate/Type/TimeSpanType.cs index 5123362a34a..ed37b4629d2 100644 --- a/src/NHibernate/Type/TimeSpanType.cs +++ b/src/NHibernate/Type/TimeSpanType.cs @@ -14,17 +14,14 @@ namespace NHibernate.Type [Serializable] public partial class TimeSpanType : PrimitiveType, IVersionType, ILiteralType { - /// - public TimeSpanType() - : base(SqlTypeFactory.Int64) + private static readonly object ZeroObject = TimeSpan.Zero; + + public TimeSpanType() : base(SqlTypeFactory.Int64) { } /// - public override string Name - { - get { return "TimeSpan"; } - } + public override string Name => "TimeSpan"; public override object Get(DbDataReader rs, int index, ISessionImplementor session) { @@ -39,10 +36,7 @@ public override object Get(DbDataReader rs, int index, ISessionImplementor sessi } /// - public override System.Type ReturnedClass - { - get { return typeof(TimeSpan); } - } + public override System.Type ReturnedClass => typeof(TimeSpan); public override void Set(DbCommand st, object value, int index, ISessionImplementor session) { @@ -86,10 +80,7 @@ public object StringToObject(string xml) return TimeSpan.Parse(xml); } - public IComparer Comparator - { - get { return Comparer.Default; } - } + public IComparer Comparator => Comparer.Default; #endregion @@ -104,15 +95,9 @@ public override object FromStringValue(string xml) return TimeSpan.Parse(xml); } - public override System.Type PrimitiveClass - { - get { return typeof(TimeSpan); } - } + public override System.Type PrimitiveClass => typeof(TimeSpan); - public override object DefaultValue - { - get { return TimeSpan.Zero; } - } + public override object DefaultValue => ZeroObject; public override string ObjectToSQLString(object value, Dialect.Dialect dialect) { diff --git a/src/NHibernate/Type/UInt16Type.cs b/src/NHibernate/Type/UInt16Type.cs index ae50718c1e2..c37bbfaca75 100644 --- a/src/NHibernate/Type/UInt16Type.cs +++ b/src/NHibernate/Type/UInt16Type.cs @@ -16,18 +16,16 @@ namespace NHibernate.Type [Serializable] public partial class UInt16Type : PrimitiveType, IDiscriminatorType, IVersionType { - /// + private static readonly object ZeroObject = (ushort) 0; + + /// public UInt16Type() : base(SqlTypeFactory.UInt16) { } /// - public override string Name - { - get { return "UInt16"; } - } + public override string Name => "UInt16"; - private static readonly UInt16 ZERO = 0; public override object Get(DbDataReader rs, int index, ISessionImplementor session) { try @@ -44,10 +42,7 @@ public override object Get(DbDataReader rs, int index, ISessionImplementor sessi } } - public override System.Type ReturnedClass - { - get { return typeof(UInt16); } - } + public override System.Type ReturnedClass => typeof(UInt16); public override void Set(DbCommand rs, object value, int index, ISessionImplementor session) { @@ -88,22 +83,13 @@ public virtual object Seed(ISessionImplementor session) return 1; } - public IComparer Comparator - { - get { return Comparer.Default; } - } + public IComparer Comparator => Comparer.Default; #endregion - public override System.Type PrimitiveClass - { - get { return typeof(UInt16); } - } + public override System.Type PrimitiveClass => typeof(UInt16); - public override object DefaultValue - { - get { return ZERO; } - } + public override object DefaultValue => ZeroObject; public override string ObjectToSQLString(object value, Dialect.Dialect dialect) { diff --git a/src/NHibernate/Type/UInt32Type.cs b/src/NHibernate/Type/UInt32Type.cs index 0aa02ca8722..e0e30b65f2f 100644 --- a/src/NHibernate/Type/UInt32Type.cs +++ b/src/NHibernate/Type/UInt32Type.cs @@ -16,18 +16,16 @@ namespace NHibernate.Type [Serializable] public partial class UInt32Type : PrimitiveType, IDiscriminatorType, IVersionType { - /// + private static readonly object ZeroObject = 0U; + + /// public UInt32Type() : base(SqlTypeFactory.UInt32) { } /// - public override string Name - { - get { return "UInt32"; } - } + public override string Name => "UInt32"; - private static readonly UInt32 ZERO = 0; public override object Get(DbDataReader rs, int index, ISessionImplementor session) { try @@ -44,10 +42,7 @@ public override object Get(DbDataReader rs, int index, ISessionImplementor sessi } } - public override System.Type ReturnedClass - { - get { return typeof(UInt32); } - } + public override System.Type ReturnedClass => typeof(UInt32); public override void Set(DbCommand rs, object value, int index, ISessionImplementor session) { @@ -88,22 +83,13 @@ public virtual object Seed(ISessionImplementor session) return 1; } - public IComparer Comparator - { - get { return Comparer.Default; } - } + public IComparer Comparator => Comparer.Default; #endregion - public override System.Type PrimitiveClass - { - get { return typeof(UInt32); } - } + public override System.Type PrimitiveClass => typeof(UInt32); - public override object DefaultValue - { - get { return ZERO; } - } + public override object DefaultValue => ZeroObject; public override string ObjectToSQLString(object value, Dialect.Dialect dialect) { diff --git a/src/NHibernate/Type/UInt64Type.cs b/src/NHibernate/Type/UInt64Type.cs index 8c1064f6f8a..8d0c05d20b1 100644 --- a/src/NHibernate/Type/UInt64Type.cs +++ b/src/NHibernate/Type/UInt64Type.cs @@ -16,17 +16,15 @@ namespace NHibernate.Type [Serializable] public partial class UInt64Type : PrimitiveType, IDiscriminatorType, IVersionType { - /// + private static readonly object ZeroObject = 0UL; + + /// public UInt64Type() : base(SqlTypeFactory.UInt64) { } - public override string Name - { - get { return "UInt64"; } - } + public override string Name => "UInt64"; - private static readonly UInt32 ZERO = 0; public override object Get(DbDataReader rs, int index, ISessionImplementor session) { try @@ -43,10 +41,7 @@ public override object Get(DbDataReader rs, int index, ISessionImplementor sessi } } - public override System.Type ReturnedClass - { - get { return typeof(UInt64); } - } + public override System.Type ReturnedClass => typeof(UInt64); public override void Set(DbCommand rs, object value, int index, ISessionImplementor session) { @@ -87,22 +82,13 @@ public virtual object Seed(ISessionImplementor session) return 1; } - public IComparer Comparator - { - get { return Comparer.Default; } - } + public IComparer Comparator => Comparer.Default; #endregion - public override System.Type PrimitiveClass - { - get { return typeof(UInt64); } - } + public override System.Type PrimitiveClass => typeof(UInt64); - public override object DefaultValue - { - get { return ZERO; } - } + public override object DefaultValue => ZeroObject; public override string ObjectToSQLString(object value, Dialect.Dialect dialect) {