From: Kevin W. <kev...@us...> - 2004-12-31 23:56:21
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24886 Modified Files: TimestampType.cs TimeType.cs TrueFalseType.cs TypeFactory.cs TypeType.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: TimestampType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/TimestampType.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TimestampType.cs 19 Oct 2004 02:24:08 -0000 1.9 --- TimestampType.cs 31 Dec 2004 23:56:09 -0000 1.10 *************** *** 1,8 **** using System; using System.Data; - using NHibernate.SqlTypes; ! namespace NHibernate.Type { /// <summary> --- 1,7 ---- using System; using System.Data; using NHibernate.SqlTypes; ! namespace NHibernate.Type { /// <summary> *************** *** 29,49 **** public class TimestampType : ValueTypeType, IVersionType, ILiteralType { ! internal TimestampType() : base( new DateTimeSqlType() ) { } ! public override object Get(IDataReader rs, int index) { ! return Convert.ToDateTime(rs[index]); } ! public override object Get(IDataReader rs, string name) { ! return Get(rs, rs.GetOrdinal(name)); } ! public override System.Type ReturnedClass { ! get { return typeof(DateTime); } } --- 28,62 ---- public class TimestampType : ValueTypeType, IVersionType, ILiteralType { ! /// <summary></summary> ! internal TimestampType() : base( new DateTimeSqlType() ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="index"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, int index ) { ! return Convert.ToDateTime( rs[ index ] ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="name"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, string name ) { ! return Get( rs, rs.GetOrdinal( name ) ); } ! /// <summary></summary> ! public override System.Type ReturnedClass { ! get { return typeof( DateTime ); } } *************** *** 57,69 **** /// No null values will be written to the IDbCommand for this Type. /// </remarks> ! public override void Set(IDbCommand st, object value, int index) { ! IDataParameter parm = st.Parameters[index] as IDataParameter; ! if( !(value is DateTime) ) { parm.Value = DateTime.Now; } ! else { parm.Value = value; --- 70,82 ---- /// No null values will be written to the IDbCommand for this Type. /// </remarks> ! public override void Set( IDbCommand st, object value, int index ) { ! IDataParameter parm = st.Parameters[ index ] as IDataParameter; ! if( !( value is DateTime ) ) { parm.Value = DateTime.Now; } ! else { parm.Value = value; *************** *** 71,95 **** } ! public override string Name { get { return "Timestamp"; } } ! public override string ToXML(object val) { ! return ((DateTime)val).ToShortTimeString(); } ! public override bool Equals(object x, object y) { ! if (x==y) return true; ! if (x==null || y==null) return false; ! long xTime = ((DateTime)x).Ticks; ! long yTime = ((DateTime)y).Ticks; return xTime == yTime; //TODO: Fixup } ! public override bool HasNiceEquals { get { return true; } --- 84,127 ---- } ! /// <summary></summary> ! public override string Name { get { return "Timestamp"; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="val"></param> ! /// <returns></returns> ! public override string ToXML( object val ) { ! return ( ( DateTime ) val ).ToShortTimeString(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="x"></param> ! /// <param name="y"></param> ! /// <returns></returns> ! public override bool Equals( object x, object y ) { ! if( x == y ) ! { ! return true; ! } ! if( x == null || y == null ) ! { ! return false; ! } ! long xTime = ( ( DateTime ) x ).Ticks; ! long yTime = ( ( DateTime ) y ).Ticks; return xTime == yTime; //TODO: Fixup } ! /// <summary></summary> ! public override bool HasNiceEquals { get { return true; } *************** *** 98,107 **** #region IVersionType Members ! public object Next(object current) { return Seed; } ! ! public object Seed { get { return DateTime.Now; } --- 130,145 ---- #region IVersionType Members ! /// <summary> ! /// ! /// </summary> ! /// <param name="current"></param> ! /// <returns></returns> ! public object Next( object current ) { return Seed; } ! ! /// <summary></summary> ! public object Seed { get { return DateTime.Now; } *************** *** 110,117 **** #endregion ! public override string ObjectToSQLString(object value) { return "'" + value.ToString() + "'"; } } ! } --- 148,160 ---- #endregion ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public override string ObjectToSQLString( object value ) { return "'" + value.ToString() + "'"; } } ! } \ No newline at end of file Index: TimeType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/TimeType.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TimeType.cs 3 Nov 2004 03:37:06 -0000 1.8 --- TimeType.cs 31 Dec 2004 23:56:09 -0000 1.9 *************** *** 3,9 **** using NHibernate.SqlTypes; ! namespace NHibernate.Type { - /// <summary> /// Maps a <see cref="System.DateTime" /> Property to an DateTime column that only stores the --- 3,8 ---- using NHibernate.SqlTypes; ! namespace NHibernate.Type { /// <summary> /// Maps a <see cref="System.DateTime" /> Property to an DateTime column that only stores the *************** *** 25,56 **** private static DateTime BaseDateValue = new DateTime( 1753, 01, 01 ); ! internal TimeType() : base( new TimeSqlType() ) { } ! public override object Get(IDataReader rs, int index) { ! DateTime dbValue = Convert.ToDateTime(rs[index]); ! return new DateTime(1753, 01, 01, dbValue.Hour, dbValue.Minute, dbValue.Second); } ! public override object Get(IDataReader rs, string name) { ! return Get(rs, rs.GetOrdinal(name)); } ! public override System.Type ReturnedClass { ! get { return typeof(DateTime); } } ! public override void Set(IDbCommand st, object value, int index) { ! IDataParameter parm = st.Parameters[index] as IDataParameter; ! if( (DateTime)value < TimeType.BaseDateValue ) { parm.Value = DBNull.Value; } ! else { parm.Value = value; --- 24,75 ---- private static DateTime BaseDateValue = new DateTime( 1753, 01, 01 ); ! /// <summary></summary> ! internal TimeType() : base( new TimeSqlType() ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="index"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, int index ) { ! DateTime dbValue = Convert.ToDateTime( rs[ index ] ); ! return new DateTime( 1753, 01, 01, dbValue.Hour, dbValue.Minute, dbValue.Second ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="name"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, string name ) { ! return Get( rs, rs.GetOrdinal( name ) ); } ! /// <summary></summary> ! public override System.Type ReturnedClass { ! get { return typeof( DateTime ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="st"></param> ! /// <param name="value"></param> ! /// <param name="index"></param> ! public override void Set( IDbCommand st, object value, int index ) { ! IDataParameter parm = st.Parameters[ index ] as IDataParameter; ! if( ( DateTime ) value < TimeType.BaseDateValue ) { parm.Value = DBNull.Value; } ! else { parm.Value = value; *************** *** 58,99 **** } ! public override bool Equals(object x, object y) { ! if (x==y) return true; ! if (x==null || y==null) return false; ! DateTime date1 = (DateTime) x; ! DateTime date2 = (DateTime) y; return date1.Hour == date2.Hour ! && date1.Minute== date2.Minute && date1.Second == date2.Second; } ! public override string Name { get { return "Time"; } } ! public override string ToXML(object val) { ! return ((DateTime)val).ToShortTimeString(); } ! public override bool HasNiceEquals { get { return true; } } ! public object StringToObject(string xml) { ! return DateTime.Parse(xml); } ! public override string ObjectToSQLString(object value) { ! return "'" + ((DateTime)value).ToShortTimeString() + "'"; } } ! } ! --- 77,146 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="x"></param> ! /// <param name="y"></param> ! /// <returns></returns> ! public override bool Equals( object x, object y ) { ! if( x == y ) ! { ! return true; ! } ! if( x == null || y == null ) ! { ! return false; ! } ! DateTime date1 = ( DateTime ) x; ! DateTime date2 = ( DateTime ) y; return date1.Hour == date2.Hour ! && date1.Minute == date2.Minute && date1.Second == date2.Second; } ! /// <summary></summary> ! public override string Name { get { return "Time"; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="val"></param> ! /// <returns></returns> ! public override string ToXML( object val ) { ! return ( ( DateTime ) val ).ToShortTimeString(); } ! /// <summary></summary> ! public override bool HasNiceEquals { get { return true; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="xml"></param> ! /// <returns></returns> ! public object StringToObject( string xml ) { ! return DateTime.Parse( xml ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public override string ObjectToSQLString( object value ) { ! return "'" + ( ( DateTime ) value ).ToShortTimeString() + "'"; } } ! } \ No newline at end of file Index: TypeType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/TypeType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TypeType.cs 25 Oct 2004 05:37:56 -0000 1.4 --- TypeType.cs 31 Dec 2004 23:56:09 -0000 1.5 *************** *** 1,18 **** using System; using System.Data; - using NHibernate.SqlTypes; using NHibernate.Util; ! namespace NHibernate.Type { ! /// <summary> /// Maps the Assembly Qualified Name of a <see cref="System.Type"/> to a ! /// <see cref="DbType.Stirng" /> column. /// </summary> ! public class TypeType : ImmutableType { ! ! internal TypeType() : base( new StringSqlType() ) { } --- 1,17 ---- using System; using System.Data; using NHibernate.SqlTypes; using NHibernate.Util; ! namespace NHibernate.Type ! { /// <summary> /// Maps the Assembly Qualified Name of a <see cref="System.Type"/> to a ! /// <see cref="DbType.String" /> column. /// </summary> ! public class TypeType : ImmutableType { ! /// <summary></summary> ! internal TypeType() : base( new StringSqlType() ) { } *************** *** 23,27 **** /// </summary> /// <param name="sqlType">The underlying <see cref="SqlType"/>.</param> ! internal TypeType(StringSqlType sqlType) : base(sqlType) { } --- 22,26 ---- /// </summary> /// <param name="sqlType">The underlying <see cref="SqlType"/>.</param> ! internal TypeType( StringSqlType sqlType ) : base( sqlType ) { } *************** *** 36,55 **** /// Thrown when the value in the database can not be loaded as a <see cref="System.Type"/> /// </exception> ! public override object Get(IDataReader rs, int index) { ! string str = (string) NHibernate.String.Get(rs, index); ! if (str == null) { return null; } ! else { ! try { ! return ReflectHelper.ClassForName(str); } ! catch (TypeLoadException) { ! throw new HibernateException("Class not found: " + str); } } --- 35,54 ---- /// Thrown when the value in the database can not be loaded as a <see cref="System.Type"/> /// </exception> ! public override object Get( IDataReader rs, int index ) { ! string str = ( string ) NHibernate.String.Get( rs, index ); ! if( str == null ) { return null; } ! else { ! try { ! return ReflectHelper.ClassForName( str ); } ! catch( TypeLoadException ) { ! throw new HibernateException( "Class not found: " + str ); } } *************** *** 71,77 **** /// Thrown when the value in the database can not be loaded as a <see cref="System.Type"/> /// </exception> ! public override object Get(IDataReader rs, string name) { ! return Get(rs, rs.GetOrdinal(name)); } --- 70,76 ---- /// Thrown when the value in the database can not be loaded as a <see cref="System.Type"/> /// </exception> ! public override object Get( IDataReader rs, string name ) { ! return Get( rs, rs.GetOrdinal( name ) ); } *************** *** 88,107 **** /// <see cref="NHibernate.String"/> object to do the work. /// </remarks> ! public override void Set(IDbCommand cmd, object value, int index) { ! NHibernate.String.Set(cmd, ( (System.Type) value ).AssemblyQualifiedName, index); } ! /// <summary> /// A representation of the value to be embedded in an XML element /// </summary> ! /// <param name="val">The <see cref="System.Type"/> that contains the values. /// </param> /// <returns>An Xml formatted string that contains the Assembly Qualified Name.</returns> ! public override string ToXML(object value) { ! return ( (System.Type) value ).AssemblyQualifiedName; } ! /// <summary> /// Gets the <see cref="System.Type"/> that will be returned --- 87,106 ---- /// <see cref="NHibernate.String"/> object to do the work. /// </remarks> ! public override void Set( IDbCommand cmd, object value, int index ) { ! NHibernate.String.Set( cmd, ( ( System.Type ) value ).AssemblyQualifiedName, index ); } ! /// <summary> /// A representation of the value to be embedded in an XML element /// </summary> ! /// <param name="value">The <see cref="System.Type"/> that contains the values. /// </param> /// <returns>An Xml formatted string that contains the Assembly Qualified Name.</returns> ! public override string ToXML( object value ) { ! return ( ( System.Type ) value ).AssemblyQualifiedName; } ! /// <summary> /// Gets the <see cref="System.Type"/> that will be returned *************** *** 111,136 **** /// A <see cref="System.Type"/> from the .NET framework. /// </value> ! public override System.Type ReturnedClass { ! get { return typeof(System.Type); } } ! ! public override bool Equals(object x, object y) { ! ! if(x==null && y==null) { return true; } ! ! if(x==null || y==null) { return false; } ! return x.Equals(y); } ! ! public override string Name { get { return "Type"; } --- 110,141 ---- /// A <see cref="System.Type"/> from the .NET framework. /// </value> ! public override System.Type ReturnedClass { ! get { return typeof( System.Type ); } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="x"></param> ! /// <param name="y"></param> ! /// <returns></returns> ! public override bool Equals( object x, object y ) { ! if( x == null && y == null ) { return true; } ! ! if( x == null || y == null ) { return false; } ! return x.Equals( y ); } ! ! /// <summary></summary> ! public override string Name { get { return "Type"; } Index: TypeFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/TypeFactory.cs,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** TypeFactory.cs 11 Dec 2004 20:08:20 -0000 1.40 --- TypeFactory.cs 31 Dec 2004 23:56:09 -0000 1.41 *************** *** 2,16 **** using System.Collections; using System.Globalization; - - using NHibernate; - using NHibernate.Collection; using NHibernate.Engine; using NHibernate.SqlTypes; - using NHibernate.Type; using NHibernate.Util; [...1587 lines suppressed...] ! { ! results = new int[types.Length]; ! } ! results[ count++ ] = i; } } ! if( count == 0 ) { return null; } ! else { ! int[ ] trimmed = new int[count]; ! System.Array.Copy( results, 0, trimmed, 0, count ); return trimmed; } } ! /* /// <summary> Index: TrueFalseType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/TrueFalseType.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TrueFalseType.cs 25 Oct 2004 05:37:56 -0000 1.5 --- TrueFalseType.cs 31 Dec 2004 23:56:09 -0000 1.6 *************** *** 1,4 **** - using System; - using NHibernate.SqlTypes; --- 1,2 ---- *************** *** 6,10 **** { /// <summary> ! /// Maps a <see cref="System.Boolean" /> to a 1 char <see cref="DbType.AnsiStringFixedLength" /> column /// that stores a <code>'T'/'F'</code> to indicate <code>true/false</code>. /// </summary> --- 4,8 ---- { /// <summary> ! /// Maps a <see cref="System.Boolean" /> to a 1 char <see cref="System.Data.DbType.AnsiStringFixedLength" /> column /// that stores a <code>'T'/'F'</code> to indicate <code>true/false</code>. /// </summary> *************** *** 17,35 **** /// export to create a char(1) column. /// </remarks> ! public class TrueFalseType: CharBooleanType { ! internal TrueFalseType() : base( new AnsiStringFixedLengthSqlType(1) ) { } ! protected override sealed string TrueString { get { return "T"; } } ! protected override sealed string FalseString { get { return "F"; } } ! public override string Name { get { return "TrueFalse"; } } --- 15,40 ---- /// export to create a char(1) column. /// </remarks> ! public class TrueFalseType : CharBooleanType { ! /// <summary></summary> ! internal TrueFalseType() : base( new AnsiStringFixedLengthSqlType( 1 ) ) { } ! /// <summary></summary> ! protected override sealed string TrueString ! { get { return "T"; } } ! /// <summary></summary> ! protected override sealed string FalseString ! { get { return "F"; } } ! /// <summary></summary> ! public override string Name ! { get { return "TrueFalse"; } } |