You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Kevin W. <kev...@us...> - 2004-12-31 23:52:31
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24224 Modified Files: CustomType.cs DateTimeType.cs DateType.cs DecimalType.cs DoubleType.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: DoubleType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/DoubleType.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** DoubleType.cs 25 Oct 2004 05:37:56 -0000 1.7 --- DoubleType.cs 31 Dec 2004 23:52:20 -0000 1.8 *************** *** 1,44 **** using System; using System.Data; - using NHibernate.SqlTypes; ! namespace NHibernate.Type { ! /// <summary> /// Maps a <see cref="System.Double"/> Property /// to a <see cref="DbType.Double"/> column. /// </summary> ! public class DoubleType : ValueTypeType { ! ! internal DoubleType() : base( new DoubleSqlType() ) { } ! public override object Get(IDataReader rs, int index) { ! return Convert.ToDouble(rs[index]); } ! public override object Get(IDataReader rs, string name) { ! return Convert.ToDouble(rs[name]); } ! public override System.Type ReturnedClass { ! get { return typeof(double); } } ! public override void Set(IDbCommand st, object value, int index) { ! IDataParameter parm = st.Parameters[index] as IDataParameter; parm.Value = value; } ! public override string Name { get { return "Double"; } } ! public override string ObjectToSQLString(object value) { return value.ToString(); } } ! } --- 1,74 ---- using System; using System.Data; using NHibernate.SqlTypes; ! namespace NHibernate.Type ! { /// <summary> /// Maps a <see cref="System.Double"/> Property /// to a <see cref="DbType.Double"/> column. /// </summary> ! public class DoubleType : ValueTypeType { ! /// <summary></summary> ! internal DoubleType() : base( new DoubleSqlType() ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="index"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, int index ) ! { ! return Convert.ToDouble( rs[ index ] ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="name"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, string name ) ! { ! return Convert.ToDouble( rs[ name ] ); } ! /// <summary></summary> ! public override System.Type ReturnedClass ! { ! get { return typeof( double ); } } ! /// <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; parm.Value = value; } ! /// <summary></summary> ! public override string Name ! { get { return "Double"; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public override string ObjectToSQLString( object value ) ! { return value.ToString(); } } ! } \ No newline at end of file Index: DateTimeType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/DateTimeType.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DateTimeType.cs 25 Oct 2004 05:37:56 -0000 1.12 --- DateTimeType.cs 31 Dec 2004 23:52:20 -0000 1.13 *************** *** 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> *************** *** 17,97 **** public class DateTimeType : ValueTypeType, IIdentifierType, ILiteralType, IVersionType { ! ! internal DateTimeType() : base( new DateTimeSqlType() ) { } ! public override object Get(IDataReader rs, int index) { ! DateTime dbValue = Convert.ToDateTime(rs[index]); ! return new DateTime(dbValue.Year, dbValue.Month, dbValue.Day, dbValue.Hour, dbValue.Minute, dbValue.Second); } ! public override object Get(IDataReader rs, string name) { ! return Get(rs,rs.GetOrdinal(name));// rs.[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; parm.DbType = DbType.DateTime; //TODO: figure out if this is a good solution for NULL DATES ! if((DateTime)value<new DateTime(1753,1,1)) { parm.Value = DBNull.Value; } ! else { ! DateTime dateValue = (DateTime)value; ! parm.Value = new DateTime(dateValue.Year, dateValue.Month, dateValue.Day, dateValue.Hour, dateValue.Minute, dateValue.Second); } } ! public override bool Equals(object x, object y) { ! if (x==y) return true; // DateTime can't be null because it is a struct - so comparing // them this way is useless - instead use the magic number... //if (x==null || y==null) return false; ! DateTime date1 = (x==null)? DateTime.MinValue : (DateTime) x; ! DateTime date2 = (y==null)? DateTime.MinValue : (DateTime) y; //return date1.Equals(date2); ! return (date1.Year == date2.Year && date1.Month == date2.Month && date1.Day == date2.Day && date1.Hour == date2.Hour && date1.Minute == date2.Minute && ! date1.Second == date2.Second); } ! public override string Name { get { return "DateTime"; } } ! public override string ToXML(object val) { ! return ((DateTime)val).ToShortDateString(); } ! public override bool HasNiceEquals { get { return true; } } ! public object StringToObject(string xml) { ! return DateTime.Parse(xml); } ! public override string ObjectToSQLString(object value) { return "'" + value.ToString() + "'"; --- 16,141 ---- public class DateTimeType : ValueTypeType, IIdentifierType, ILiteralType, IVersionType { ! /// <summary></summary> ! internal DateTimeType() : base( new DateTimeSqlType() ) { } ! /// <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( dbValue.Year, dbValue.Month, dbValue.Day, 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 ) ); // rs.[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; parm.DbType = DbType.DateTime; //TODO: figure out if this is a good solution for NULL DATES ! if( ( DateTime ) value < new DateTime( 1753, 1, 1 ) ) { parm.Value = DBNull.Value; } ! else { ! DateTime dateValue = ( DateTime ) value; ! parm.Value = new DateTime( dateValue.Year, dateValue.Month, dateValue.Day, dateValue.Hour, dateValue.Minute, dateValue.Second ); } } ! /// <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; ! } // DateTime can't be null because it is a struct - so comparing // them this way is useless - instead use the magic number... //if (x==null || y==null) return false; ! DateTime date1 = ( x == null ) ? DateTime.MinValue : ( DateTime ) x; ! DateTime date2 = ( y == null ) ? DateTime.MinValue : ( DateTime ) y; //return date1.Equals(date2); ! return ( date1.Year == date2.Year && date1.Month == date2.Month && date1.Day == date2.Day && date1.Hour == date2.Hour && date1.Minute == date2.Minute && ! date1.Second == date2.Second ); } ! /// <summary></summary> ! public override string Name { get { return "DateTime"; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="val"></param> ! /// <returns></returns> ! public override string ToXML( object val ) { ! return ( ( DateTime ) val ).ToShortDateString(); } ! /// <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 "'" + value.ToString() + "'"; *************** *** 100,109 **** #region IVersionType Members ! public object Next(object current) { return Seed; } ! ! public object Seed { get { return DateTime.Now; } --- 144,159 ---- #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; } *************** *** 111,115 **** #endregion - } ! } --- 161,164 ---- #endregion } ! } \ No newline at end of file Index: CustomType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/CustomType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CustomType.cs 10 Feb 2004 18:41:42 -0000 1.3 --- CustomType.cs 31 Dec 2004 23:52:20 -0000 1.4 *************** *** 1,83 **** using System; - using System.Reflection; using System.Data; ! using log4net; using NHibernate.Engine; using NHibernate.SqlTypes; ! namespace NHibernate.Type { ! /// <summary> /// Adapts IUserType to the generic IType interface. ! /// <seealso cref="NHibernate.IUserType"/> /// </summary> ! public class CustomType : AbstractType { ! private readonly IUserType userType; private readonly string name; ! private readonly SqlType[] sqlTypes; ! protected IUserType UserType { ! get { ! return userType; ! } } ! public CustomType(System.Type userTypeClass) { name = userTypeClass.Name; ! try { ! userType = (IUserType) Activator.CreateInstance(userTypeClass); } ! catch (ArgumentNullException ane) { throw new MappingException( "Argument is a null reference.", ane ); } ! catch (ArgumentException ae) { throw new MappingException( "Argument " + userTypeClass.Name + " is not a RuntimeType", ae ); } ! catch (TargetInvocationException tie) { throw new MappingException( "The constructor being called throws an exception.", tie ); } ! catch (MethodAccessException mae) { throw new MappingException( "The caller does not have permission to call this constructor.", mae ); } ! catch (MissingMethodException mme) { throw new MappingException( "No matching constructor was found.", mme ); } ! catch (InvalidCastException ice) { throw new MappingException( userTypeClass.Name + " must implement NHibernate.IUserType", ice ); } sqlTypes = userType.SqlTypes; ! if ( !userType.ReturnedType.IsSerializable ) { ! LogManager.GetLogger(typeof(CustomType)).Warn("custom type is not Serializable: " + userTypeClass); } } ! ! public override SqlType[] SqlTypes(IMapping mapping) { return sqlTypes; } ! public override int GetColumnSpan(IMapping session) { return sqlTypes.Length; } ! ! public override System.Type ReturnedClass { get { return userType.ReturnedType; } } ! ! public override bool Equals(object x, object y) { ! return userType.Equals(x, y); } ! public override object NullSafeGet( IDataReader rs, ! string[] names, ISessionImplementor session, object owner ! ) { ! return userType.NullSafeGet(rs, names, owner); } ! public override object NullSafeGet( IDataReader rs, --- 1,133 ---- using System; using System.Data; ! using System.Reflection; using log4net; using NHibernate.Engine; using NHibernate.SqlTypes; ! namespace NHibernate.Type ! { /// <summary> /// Adapts IUserType to the generic IType interface. ! /// <seealso cref="IUserType"/> /// </summary> ! public class CustomType : AbstractType ! { private readonly IUserType userType; private readonly string name; ! private readonly SqlType[ ] sqlTypes; ! /// <summary></summary> ! protected IUserType UserType ! { ! get { return userType; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="userTypeClass"></param> ! public CustomType( System.Type userTypeClass ) ! { name = userTypeClass.Name; ! try ! { ! userType = ( IUserType ) Activator.CreateInstance( userTypeClass ); } ! catch( ArgumentNullException ane ) ! { throw new MappingException( "Argument is a null reference.", ane ); } ! catch( ArgumentException ae ) ! { throw new MappingException( "Argument " + userTypeClass.Name + " is not a RuntimeType", ae ); } ! catch( TargetInvocationException tie ) ! { throw new MappingException( "The constructor being called throws an exception.", tie ); } ! catch( MethodAccessException mae ) ! { throw new MappingException( "The caller does not have permission to call this constructor.", mae ); } ! catch( MissingMethodException mme ) ! { throw new MappingException( "No matching constructor was found.", mme ); } ! catch( InvalidCastException ice ) ! { throw new MappingException( userTypeClass.Name + " must implement NHibernate.IUserType", ice ); } sqlTypes = userType.SqlTypes; ! if( !userType.ReturnedType.IsSerializable ) ! { ! LogManager.GetLogger( typeof( CustomType ) ).Warn( "custom type is not Serializable: " + userTypeClass ); } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="mapping"></param> ! /// <returns></returns> ! public override SqlType[ ] SqlTypes( IMapping mapping ) ! { return sqlTypes; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <returns></returns> ! public override int GetColumnSpan( IMapping session ) ! { return sqlTypes.Length; } ! ! /// <summary></summary> ! public override System.Type ReturnedClass ! { get { return userType.ReturnedType; } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="x"></param> ! /// <param name="y"></param> ! /// <returns></returns> ! public override bool Equals( object x, object y ) ! { ! return userType.Equals( x, y ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="names"></param> ! /// <param name="session"></param> ! /// <param name="owner"></param> ! /// <returns></returns> public override object NullSafeGet( IDataReader rs, ! string[ ] names, ISessionImplementor session, object owner ! ) ! { ! return userType.NullSafeGet( rs, names, owner ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="name"></param> ! /// <param name="session"></param> ! /// <param name="owner"></param> ! /// <returns></returns> public override object NullSafeGet( IDataReader rs, *************** *** 85,92 **** ISessionImplementor session, object owner ! ) { ! return NullSafeGet(rs, new string[] { name }, session, owner); } ! public override void NullSafeSet( IDbCommand cmd, --- 135,150 ---- ISessionImplementor session, object owner ! ) ! { ! return NullSafeGet( rs, new string[ ] {name}, session, owner ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="cmd"></param> ! /// <param name="value"></param> ! /// <param name="index"></param> ! /// <param name="session"></param> public override void NullSafeSet( IDbCommand cmd, *************** *** 94,118 **** int index, ISessionImplementor session ! ) { ! userType.NullSafeSet(cmd, value, index); } ! ! public override string ToXML(object value, ISessionFactoryImplementor factory) { return value.ToString(); } ! ! public override string Name { get { return name; } } ! ! public override object DeepCopy(object value) { ! return userType.DeepCopy(value); } ! ! public override bool IsMutable { get { return userType.IsMutable; } } ! ! public override bool HasNiceEquals { get { return false; } } --- 152,196 ---- int index, ISessionImplementor session ! ) ! { ! userType.NullSafeSet( cmd, value, index ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <param name="factory"></param> ! /// <returns></returns> ! public override string ToXML( object value, ISessionFactoryImplementor factory ) ! { return value.ToString(); } ! ! /// <summary></summary> ! public override string Name ! { get { return name; } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public override object DeepCopy( object value ) ! { ! return userType.DeepCopy( value ); } ! ! /// <summary></summary> ! public override bool IsMutable ! { get { return userType.IsMutable; } } ! ! /// <summary></summary> ! public override bool HasNiceEquals ! { get { return false; } } Index: DecimalType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/DecimalType.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** DecimalType.cs 25 Oct 2004 05:37:56 -0000 1.7 --- DecimalType.cs 31 Dec 2004 23:52:20 -0000 1.8 *************** *** 1,10 **** using System; using System.Data; - using NHibernate.SqlTypes; ! namespace NHibernate.Type { - /// <summary> /// Maps a <see cref="System.Decimal"/> Property --- 1,8 ---- using System; using System.Data; using NHibernate.SqlTypes; ! namespace NHibernate.Type { /// <summary> /// Maps a <see cref="System.Decimal"/> Property *************** *** 13,56 **** public class DecimalType : ValueTypeType, IIdentifierType { ! internal DecimalType() : this( new DecimalSqlType() ) { } ! ! internal DecimalType(DecimalSqlType sqlType) : base(sqlType) { } ! public override object Get(IDataReader rs, int index) { ! return Convert.ToDecimal(rs[index]); } ! public override object Get(IDataReader rs, string name) { ! return Convert.ToDecimal(rs[name]); } ! public override System.Type ReturnedClass { ! get { return typeof(Decimal); } } ! public override void Set(IDbCommand st, object value, int index) { ! IDataParameter parm = st.Parameters[index] as IDataParameter; parm.Value = value; } ! public override string Name { get { return "Decimal"; } } ! public object StringToObject(string xml) { ! return long.Parse(xml); } ! public override string ObjectToSQLString(object value) { return value.ToString(); --- 11,89 ---- public class DecimalType : ValueTypeType, IIdentifierType { ! /// <summary></summary> ! internal DecimalType() : this( new DecimalSqlType() ) { } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlType"></param> ! internal DecimalType( DecimalSqlType sqlType ) : base( sqlType ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="index"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, int index ) { ! return Convert.ToDecimal( rs[ index ] ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="name"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, string name ) { ! return Convert.ToDecimal( rs[ name ] ); } ! /// <summary></summary> ! public override System.Type ReturnedClass { ! get { return typeof( Decimal ); } } ! /// <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; parm.Value = value; } ! /// <summary></summary> ! public override string Name { get { return "Decimal"; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="xml"></param> ! /// <returns></returns> ! public object StringToObject( string xml ) { ! return long.Parse( xml ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public override string ObjectToSQLString( object value ) { return value.ToString(); Index: DateType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/DateType.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DateType.cs 25 Oct 2004 05:37:56 -0000 1.12 --- DateType.cs 31 Dec 2004 23:52:20 -0000 1.13 *************** *** 3,45 **** using NHibernate.SqlTypes; ! namespace NHibernate.Type { - /// <summary> /// Maps the Year, Month, and Day of a <see cref="System.DateTime"/> Property to a /// <see cref="DbType.Date"/> column /// </summary> ! public class DateType : ValueTypeType, IIdentifierType, ILiteralType { ! ! internal DateType() : base( new DateSqlType() ) { } ! public override object Get(IDataReader rs, int index) { ! DateTime dbValue = Convert.ToDateTime(rs[index]); ! return new DateTime(dbValue.Year, dbValue.Month, dbValue.Day); } ! 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<new DateTime(1753,1,1)) { parm.Value = DBNull.Value; } ! else { - parm.DbType = DbType.Date; parm.Value = value; --- 3,63 ---- using NHibernate.SqlTypes; ! namespace NHibernate.Type { /// <summary> /// Maps the Year, Month, and Day of a <see cref="System.DateTime"/> Property to a /// <see cref="DbType.Date"/> column /// </summary> ! public class DateType : ValueTypeType, IIdentifierType, ILiteralType { ! /// <summary></summary> ! internal DateType() : base( new DateSqlType() ) { } ! /// <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( dbValue.Year, dbValue.Month, dbValue.Day ); } ! /// <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 < new DateTime( 1753, 1, 1 ) ) { parm.Value = DBNull.Value; } ! else { parm.DbType = DbType.Date; parm.Value = value; *************** *** 47,81 **** } ! 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.Day == date2.Day ! && date1.Month == date2.Month && date1.Year == date2.Year; } ! public override string Name { get { return "Date"; } } ! public override string ToXML(object val) { ! return ((DateTime)val).ToShortDateString(); } ! 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).ToShortDateString() + "'"; } } ! } --- 65,134 ---- } ! /// <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.Day == date2.Day ! && date1.Month == date2.Month && date1.Year == date2.Year; } ! /// <summary></summary> ! public override string Name ! { get { return "Date"; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="val"></param> ! /// <returns></returns> ! public override string ToXML( object val ) ! { ! return ( ( DateTime ) val ).ToShortDateString(); } ! /// <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 ).ToShortDateString() + "'"; } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 23:51:32
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24049 Modified Files: BinaryType.cs BlobType.cs BooleanType.cs ByteType.cs CharBooleanType.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: BinaryType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/BinaryType.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** BinaryType.cs 25 Oct 2004 05:37:56 -0000 1.7 --- BinaryType.cs 31 Dec 2004 23:51:19 -0000 1.8 *************** *** 3,12 **** using System.IO; using System.Text; - - using NHibernate.Cfg; using NHibernate.SqlTypes; ! namespace NHibernate.Type { ! /// <summary> /// BinaryType. --- 3,12 ---- using System.IO; using System.Text; using NHibernate.SqlTypes; + using NHibernate.Util; + using Environment = NHibernate.Cfg.Environment; ! namespace NHibernate.Type ! { /// <summary> /// BinaryType. *************** *** 14,108 **** public class BinaryType : MutableType { ! internal BinaryType() : this( new BinarySqlType() ) { } ! internal BinaryType(BinarySqlType sqlType) : base(sqlType) { } ! public override void Set(IDbCommand cmd, object value, int index) { //TODO: research into byte streams //if ( Cfg.Environment.UseStreamsForBinary ) { ! // Is this really necessary? ! // How do we do???? ! //TODO: st.setBinaryStream( index, new ByteArrayInputStream( (byte[]) value ), ( (byte[]) value ).length ); //} //else { ! //Need to set DbType in parameter???? ! ( (IDataParameter) cmd.Parameters[index] ).Value = (byte[]) value; //} } ! public override object Get(IDataReader rs, int index) { ! if ( Cfg.Environment.UseStreamsForBinary ) { // Is this really necessary? // see http://msdn.microsoft.com/library/en-us/cpguide/html/cpconobtainingblobvaluesfromdatabase.asp?frame=true // for a how to on reading binary/blob values from a db... ! MemoryStream outputStream = new MemoryStream(2048); ! byte[] buffer = new byte[2048]; long fieldOffset = 0; ! try { ! while (true) { ! long amountRead = rs.GetBytes(index, fieldOffset, buffer, 0, 2048); ! ! if (amountRead == 0) break; ! fieldOffset += amountRead; ! outputStream.Write(buffer,0,(int)amountRead); } outputStream.Close(); } ! catch (IOException ioe) { throw new HibernateException( "IOException occurred reading a binary value", ioe ); } ! return outputStream.ToArray(); ! } ! else { //TODO: not sure if this will work with all dbs ! return (byte[])rs[index]; } } ! public override object Get(IDataReader rs, string name) { ! return Get(rs, rs.GetOrdinal(name)); } ! ! public override System.Type ReturnedClass { ! get { return typeof(byte[]); } } - - public override bool Equals(object x, object y) { - if (x==y) return true; - if (x==null || y==null) return false; ! return Util.ArrayHelper.Equals((byte[])x, (byte[])y); ! } ! ! public override string Name { get { return "Byte[]"; } } ! ! public override string ToXML(object val) { ! byte[] bytes = ( byte[] ) val; StringBuilder buf = new StringBuilder(); ! for ( int i=0; i<bytes.Length; i++ ) { ! string hexStr = (bytes[i] - byte.MinValue).ToString("x"); //Why no ToBase64? ! if ( hexStr.Length==1 ) buf.Append('0'); ! buf.Append(hexStr); } return buf.ToString(); } ! ! public override object DeepCopyNotNull(Object value) { ! byte[] bytes = (byte[]) value; ! byte[] result = new byte[bytes.Length]; ! System.Array.Copy(bytes, 0, result, 0, bytes.Length); return result; } } ! } --- 14,181 ---- public class BinaryType : MutableType { ! /// <summary></summary> ! internal BinaryType() : this( new BinarySqlType() ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlType"></param> ! internal BinaryType( BinarySqlType sqlType ) : base( sqlType ) ! { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="cmd"></param> ! /// <param name="value"></param> ! /// <param name="index"></param> ! public override void Set( IDbCommand cmd, object value, int index ) ! { //TODO: research into byte streams //if ( Cfg.Environment.UseStreamsForBinary ) { ! // Is this really necessary? ! // How do we do???? ! //TODO: st.setBinaryStream( index, new ByteArrayInputStream( (byte[]) value ), ( (byte[]) value ).length ); //} //else { ! //Need to set DbType in parameter???? ! ( ( IDataParameter ) cmd.Parameters[ index ] ).Value = ( byte[ ] ) value; //} } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="index"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, int index ) ! { ! if( Environment.UseStreamsForBinary ) ! { // Is this really necessary? // see http://msdn.microsoft.com/library/en-us/cpguide/html/cpconobtainingblobvaluesfromdatabase.asp?frame=true // for a how to on reading binary/blob values from a db... ! MemoryStream outputStream = new MemoryStream( 2048 ); ! byte[ ] buffer = new byte[2048]; long fieldOffset = 0; ! try ! { ! while( true ) ! { ! long amountRead = rs.GetBytes( index, fieldOffset, buffer, 0, 2048 ); ! ! if( amountRead == 0 ) ! { ! break; ! } ! fieldOffset += amountRead; ! outputStream.Write( buffer, 0, ( int ) amountRead ); } outputStream.Close(); } ! catch( IOException ioe ) ! { throw new HibernateException( "IOException occurred reading a binary value", ioe ); } ! return outputStream.ToArray(); ! } ! else ! { //TODO: not sure if this will work with all dbs ! return ( byte[ ] ) 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( byte[ ] ); } } ! /// <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; ! } ! ! return ArrayHelper.Equals( ( byte[ ] ) x, ( byte[ ] ) y ); } ! ! /// <summary></summary> ! public override int GetHashCode() ! { ! return base.GetHashCode(); ! } ! ! /// <summary></summary> ! public override string Name ! { get { return "Byte[]"; } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="val"></param> ! /// <returns></returns> ! public override string ToXML( object val ) ! { ! byte[ ] bytes = ( byte[ ] ) val; StringBuilder buf = new StringBuilder(); ! for( int i = 0; i < bytes.Length; i++ ) ! { ! string hexStr = ( bytes[ i ] - byte.MinValue ).ToString( "x" ); //Why no ToBase64? ! if( hexStr.Length == 1 ) ! { ! buf.Append( '0' ); ! } ! buf.Append( hexStr ); } return buf.ToString(); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public override object DeepCopyNotNull( Object value ) ! { ! byte[ ] bytes = ( byte[ ] ) value; ! byte[ ] result = new byte[bytes.Length]; ! Array.Copy( bytes, 0, result, 0, bytes.Length ); return result; } } ! } \ No newline at end of file Index: CharBooleanType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/CharBooleanType.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CharBooleanType.cs 21 Nov 2004 22:56:31 -0000 1.8 --- CharBooleanType.cs 31 Dec 2004 23:51:19 -0000 1.9 *************** *** 1,57 **** using System; using System.Data; - using NHibernate.SqlTypes; ! namespace NHibernate.Type { ! /// <summary> /// Maps a <see cref="System.Boolean"/> Property /// to a <see cref="DbType.AnsiStringFixedLength"/> column. /// </summary> ! public abstract class CharBooleanType : BooleanType { ! protected abstract string TrueString { get; } protected abstract string FalseString { get; } ! internal CharBooleanType(AnsiStringFixedLengthSqlType sqlType) : base(sqlType) { } ! public override object Get(IDataReader rs, int index) { ! string code = Convert.ToString(rs[index]); ! if (code==null) { return null; } ! else { ! return code.ToUpper().Equals(TrueString); } } ! public override object Get(IDataReader rs, string name) { ! return Get(rs, rs.GetOrdinal(name)); } ! public override void Set(IDbCommand cmd, Object value, int index) { ! ( (IDataParameter) cmd.Parameters[index] ).Value = ( ( (bool)value ) ? TrueString : FalseString ); } ! ! public override string ObjectToSQLString(object value) { ! return "'" + ( ( (bool) value ) ? TrueString : FalseString ) + "'"; } ! public override object StringToObject(String xml) { ! if( TrueString.Equals(xml) ) { return true; } ! else if( FalseString.Equals(xml) ) { return false; } ! else { ! throw new HibernateException("Could not interpret: " + xml); } } --- 1,97 ---- using System; using System.Data; using NHibernate.SqlTypes; ! namespace NHibernate.Type ! { /// <summary> /// Maps a <see cref="System.Boolean"/> Property /// to a <see cref="DbType.AnsiStringFixedLength"/> column. /// </summary> ! public abstract class CharBooleanType : BooleanType { ! /// <summary></summary> protected abstract string TrueString { get; } + + /// <summary></summary> protected abstract string FalseString { get; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlType"></param> ! internal CharBooleanType( AnsiStringFixedLengthSqlType sqlType ) : base( sqlType ) ! { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="index"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, int index ) ! { ! string code = Convert.ToString( rs[ index ] ); ! if( code == null ) ! { return null; } ! else ! { ! return code.ToUpper().Equals( TrueString ); } } ! /// <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> ! /// <param name="cmd"></param> ! /// <param name="value"></param> ! /// <param name="index"></param> ! public override void Set( IDbCommand cmd, Object value, int index ) ! { ! ( ( IDataParameter ) cmd.Parameters[ index ] ).Value = ( ( ( bool ) value ) ? TrueString : FalseString ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public override string ObjectToSQLString( object value ) ! { ! return "'" + ( ( ( bool ) value ) ? TrueString : FalseString ) + "'"; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="xml"></param> ! /// <returns></returns> ! public override object StringToObject( String xml ) { ! if( TrueString.Equals( xml ) ) { return true; } ! else if( FalseString.Equals( xml ) ) { return false; } ! else { ! throw new HibernateException( "Could not interpret: " + xml ); } } Index: BlobType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/BlobType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BlobType.cs 20 Feb 2003 21:42:13 -0000 1.1 --- BlobType.cs 31 Dec 2004 23:51:19 -0000 1.2 *************** *** 1,4 **** - using System; - namespace NHibernate.Type { --- 1,2 ---- *************** *** 8,11 **** --- 6,10 ---- public class BlobType { + /// <summary></summary> public BlobType() { *************** *** 15,17 **** } } ! } --- 14,16 ---- } } ! } \ No newline at end of file Index: ByteType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/ByteType.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ByteType.cs 25 Oct 2004 05:37:56 -0000 1.8 --- ByteType.cs 31 Dec 2004 23:51:19 -0000 1.9 *************** *** 1,47 **** using System; using System.Data; - - using NHibernate.Engine; using NHibernate.SqlTypes; ! namespace NHibernate.Type { ! /// <summary> /// Maps a <see cref="System.Byte"/> Property /// to a <see cref="DbType.Byte"/> column. /// </summary> ! public class ByteType : ValueTypeType, IDiscriminatorType { ! ! internal ByteType() : base( new ByteSqlType() ) { } ! public override object Get(IDataReader rs, int index) { ! return Convert.ToByte(rs[index]); } ! public override object Get(IDataReader rs, string name) { ! return Convert.ToByte(rs[name]); } ! public override System.Type ReturnedClass { ! get { return typeof(byte); } } ! ! public override void Set(IDbCommand cmd, object value, int index) { ! ( (IDataParameter)cmd.Parameters[index] ).Value = (byte) value; } ! public override string Name { get { return "Byte"; } } ! public override string ObjectToSQLString(object value) { return value.ToString(); } ! public virtual object StringToObject(string xml) { ! return byte.Parse(xml); } } --- 1,82 ---- using System; using System.Data; using NHibernate.SqlTypes; ! namespace NHibernate.Type ! { /// <summary> /// Maps a <see cref="System.Byte"/> Property /// to a <see cref="DbType.Byte"/> column. /// </summary> ! public class ByteType : ValueTypeType, IDiscriminatorType { ! /// <summary></summary> ! internal ByteType() : base( new ByteSqlType() ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="index"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, int index ) ! { ! return Convert.ToByte( rs[ index ] ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="name"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, string name ) ! { ! return Convert.ToByte( rs[ name ] ); } ! /// <summary></summary> ! public override System.Type ReturnedClass ! { ! get { return typeof( byte ); } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="cmd"></param> ! /// <param name="value"></param> ! /// <param name="index"></param> ! public override void Set( IDbCommand cmd, object value, int index ) ! { ! ( ( IDataParameter ) cmd.Parameters[ index ] ).Value = ( byte ) value; } ! /// <summary></summary> ! public override string Name ! { get { return "Byte"; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public override string ObjectToSQLString( object value ) ! { return value.ToString(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="xml"></param> ! /// <returns></returns> ! public virtual object StringToObject( string xml ) ! { ! return byte.Parse( xml ); } } Index: BooleanType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/BooleanType.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** BooleanType.cs 25 Oct 2004 05:37:56 -0000 1.10 --- BooleanType.cs 31 Dec 2004 23:51:19 -0000 1.11 *************** *** 1,15 **** using System; using System.Data; - using NHibernate.SqlTypes; ! namespace NHibernate.Type { ! /// <summary> /// Maps a <see cref="System.Boolean"/> Property /// to a <see cref="DbType.Boolean"/> column. /// </summary> ! public class BooleanType : ValueTypeType, IDiscriminatorType { ! private static readonly string TRUE = "1"; private static readonly string FALSE = "0"; --- 1,14 ---- using System; using System.Data; using NHibernate.SqlTypes; ! namespace NHibernate.Type ! { /// <summary> /// Maps a <see cref="System.Boolean"/> Property /// to a <see cref="DbType.Boolean"/> column. /// </summary> ! public class BooleanType : ValueTypeType, IDiscriminatorType ! { private static readonly string TRUE = "1"; private static readonly string FALSE = "0"; *************** *** 19,23 **** /// </summary> /// <remarks>This is used when the Property is mapped to a native boolean type.</remarks> ! internal BooleanType() : base( new BooleanSqlType() ) { } --- 18,22 ---- /// </summary> /// <remarks>This is used when the Property is mapped to a native boolean type.</remarks> ! internal BooleanType() : base( new BooleanSqlType() ) { } *************** *** 32,64 **** /// that stores true or false as a string. /// </remarks> ! internal BooleanType(AnsiStringFixedLengthSqlType sqlType) : base(sqlType) { } ! public override object Get(IDataReader rs, int index) { ! return Convert.ToBoolean(rs[index]); } ! public override object Get(IDataReader rs, string name) { ! return Convert.ToBoolean(rs[name]); } ! ! public override System.Type ReturnedClass { ! get { return typeof(bool); } } ! public override void Set(IDbCommand cmd, object value, int index) { ! ( (IDataParameter)cmd.Parameters[index] ).Value = (bool) value; } ! ! public override string Name { get { return "Boolean"; } } ! ! public override string ObjectToSQLString(object value) { ! return ( (bool)value ) ? TRUE : FALSE; } ! ! public virtual object StringToObject(string xml) { ! return bool.Parse(xml); } } --- 31,103 ---- /// that stores true or false as a string. /// </remarks> ! internal BooleanType( AnsiStringFixedLengthSqlType sqlType ) : base( sqlType ) ! { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="index"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, int index ) ! { ! return Convert.ToBoolean( rs[ index ] ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="name"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, string name ) ! { ! return Convert.ToBoolean( rs[ name ] ); } ! ! /// <summary> ! /// ! /// </summary> ! public override System.Type ReturnedClass ! { ! get { return typeof( bool ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="cmd"></param> ! /// <param name="value"></param> ! /// <param name="index"></param> ! public override void Set( IDbCommand cmd, object value, int index ) ! { ! ( ( IDataParameter ) cmd.Parameters[ index ] ).Value = ( bool ) value; } ! ! /// <summary></summary> ! public override string Name ! { get { return "Boolean"; } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public override string ObjectToSQLString( object value ) ! { ! return ( ( bool ) value ) ? TRUE : FALSE; } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="xml"></param> ! /// <returns></returns> ! public virtual object StringToObject( string xml ) ! { ! return bool.Parse( xml ); } } |
From: Kevin W. <kev...@us...> - 2004-12-31 23:51:10
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23974 Modified Files: AbstractType.cs AnsiStringType.cs ArrayType.cs BagType.cs BinaryBlobType.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: BagType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/BagType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BagType.cs 3 May 2004 04:52:11 -0000 1.3 --- BagType.cs 31 Dec 2004 23:50:57 -0000 1.4 *************** *** 1,5 **** - using System; using System.Collections; - using NHibernate.Collection; using NHibernate.Engine; --- 1,3 ---- *************** *** 7,38 **** namespace NHibernate.Type { ! /// <summary> ! /// ! /// </summary> public class BagType : PersistentCollectionType { ! public BagType(string role) : base(role) { } ! public override PersistentCollection Instantiate(ISessionImplementor session, CollectionPersister persister) { ! return new Bag(session); } ! public override System.Type ReturnedClass { ! get { return typeof(ICollection); } } ! public override PersistentCollection Wrap(ISessionImplementor session, object collection) { ! return new Bag(session, (ICollection)collection); } ! public override PersistentCollection AssembleCachedCollection(ISessionImplementor session, CollectionPersister persister, object disassembled, object owner) { ! return new Bag(session, persister, disassembled, owner); } --- 5,59 ---- namespace NHibernate.Type { ! /// <summary></summary> public class BagType : PersistentCollectionType { ! /// <summary> ! /// ! /// </summary> ! /// <param name="role"></param> ! public BagType( string role ) : base( role ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="persister"></param> ! /// <returns></returns> ! public override PersistentCollection Instantiate( ISessionImplementor session, CollectionPersister persister ) { ! return new Bag( session ); } ! /// <summary></summary> ! public override System.Type ReturnedClass { ! get { return typeof( ICollection ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="collection"></param> ! /// <returns></returns> ! public override PersistentCollection Wrap( ISessionImplementor session, object collection ) { ! return new Bag( session, ( ICollection ) collection ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="persister"></param> ! /// <param name="disassembled"></param> ! /// <param name="owner"></param> ! /// <returns></returns> ! public override PersistentCollection AssembleCachedCollection( ISessionImplementor session, CollectionPersister persister, object disassembled, object owner ) { ! return new Bag( session, persister, disassembled, owner ); } Index: ArrayType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/ArrayType.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ArrayType.cs 1 Jun 2004 01:36:11 -0000 1.6 --- ArrayType.cs 31 Dec 2004 23:50:57 -0000 1.7 *************** *** 1,54 **** - using System; - using System.Data; using System.Collections; using NHibernate.Collection; using NHibernate.Engine; ! namespace NHibernate.Type { ! ! public class ArrayType : PersistentCollectionType { //private System.Type elementClass; private System.Type arrayClass; ! public ArrayType(string role, System.Type elementClass) : base(role) { //this.elementClass = elementClass; ! arrayClass = Array.CreateInstance(elementClass,0).GetType(); } ! public override System.Type ReturnedClass { get { return arrayClass; } } ! public override PersistentCollection Instantiate(ISessionImplementor session, CollectionPersister persister) { ! return new ArrayHolder(session, persister); } ! public override void NullSafeSet(IDbCommand st, object value, int index, ISessionImplementor session) { ! base.NullSafeSet(st, session.GetArrayHolder(value), index, session); } ! public override ICollection GetElementsCollection(object collection) { ! return ((object[])collection); } ! public override object Disassemble(object value, ISessionImplementor session) { ! if (value==null) return null; ! return session.GetLoadedCollectionKey( session.GetArrayHolder(value) ); } ! public override PersistentCollection Wrap(ISessionImplementor session, object array) { ! return new ArrayHolder(session, array); } ! public override bool IsArrayType { get { return true; } } ! public override PersistentCollection AssembleCachedCollection( ISessionImplementor session, ! CollectionPersister persister, ! object disassembled, ! object owner ) { ! return new ArrayHolder(session, persister, disassembled, owner); } } ! } --- 1,112 ---- using System.Collections; + using System.Data; using NHibernate.Collection; using NHibernate.Engine; ! namespace NHibernate.Type ! { ! /// <summary></summary> ! public class ArrayType : PersistentCollectionType ! { //private System.Type elementClass; private System.Type arrayClass; ! /// <summary> ! /// ! /// </summary> ! /// <param name="role"></param> ! /// <param name="elementClass"></param> ! public ArrayType( string role, System.Type elementClass ) : base( role ) ! { //this.elementClass = elementClass; ! arrayClass = System.Array.CreateInstance( elementClass, 0 ).GetType(); } ! /// <summary></summary> ! public override System.Type ReturnedClass ! { get { return arrayClass; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="persister"></param> ! /// <returns></returns> ! public override PersistentCollection Instantiate( ISessionImplementor session, CollectionPersister persister ) ! { ! return new ArrayHolder( session, persister ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="st"></param> ! /// <param name="value"></param> ! /// <param name="index"></param> ! /// <param name="session"></param> ! public override void NullSafeSet( IDbCommand st, object value, int index, ISessionImplementor session ) ! { ! base.NullSafeSet( st, session.GetArrayHolder( value ), index, session ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="collection"></param> ! /// <returns></returns> ! public override ICollection GetElementsCollection( object collection ) ! { ! return ( ( object[ ] ) collection ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <param name="session"></param> ! /// <returns></returns> ! public override object Disassemble( object value, ISessionImplementor session ) ! { ! if( value == null ) ! { ! return null; ! } ! return session.GetLoadedCollectionKey( session.GetArrayHolder( value ) ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="array"></param> ! /// <returns></returns> ! public override PersistentCollection Wrap( ISessionImplementor session, object array ) ! { ! return new ArrayHolder( session, array ); } ! /// <summary></summary> ! public override bool IsArrayType ! { get { return true; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="persister"></param> ! /// <param name="disassembled"></param> ! /// <param name="owner"></param> ! /// <returns></returns> ! public override PersistentCollection AssembleCachedCollection( ISessionImplementor session, ! CollectionPersister persister, ! object disassembled, ! object owner ) ! { ! return new ArrayHolder( session, persister, disassembled, owner ); } } ! } \ No newline at end of file Index: AnsiStringType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/AnsiStringType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AnsiStringType.cs 21 Aug 2004 16:37:32 -0000 1.3 --- AnsiStringType.cs 31 Dec 2004 23:50:57 -0000 1.4 *************** *** 10,63 **** /// to a <see cref="DbType.AnsiString"/> column. /// </summary> ! public class AnsiStringType : ImmutableType, IDiscriminatorType { ! internal AnsiStringType() : base( new AnsiStringSqlType() ) { } - internal AnsiStringType(AnsiStringSqlType sqlType) : base(sqlType) {} ! public override object Get(IDataReader rs, int index) { - return Convert.ToString(rs[index]); } ! public override object Get(IDataReader rs, string name) { ! return Convert.ToString(rs[name]); } ! public override System.Type ReturnedClass { ! get { return typeof(string); } } ! public override void Set(IDbCommand st, object value, int index) { ! IDataParameter parm = st.Parameters[index] as IDataParameter; parm.Value = value; } ! public override string Name { get { return "AnsiString"; } } ! public string ObjectToSQLString(object value) { ! return "'" + (string) value + "'"; } ! public object StringToObject(string xml) { return xml; } ! public override bool Equals(object x, object y) { ! return ObjectUtils.Equals(x, y); } ! public override string ToXML(object value) { ! return (string) value; } - } - } --- 10,121 ---- /// to a <see cref="DbType.AnsiString"/> column. /// </summary> ! public class AnsiStringType : ImmutableType, IDiscriminatorType { ! /// <summary></summary> ! internal AnsiStringType() : base( new AnsiStringSqlType() ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlType"></param> ! internal AnsiStringType( AnsiStringSqlType sqlType ) : base( sqlType ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="index"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, int index ) { ! return Convert.ToString( rs[ index ] ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="rs"></param> ! /// <param name="name"></param> ! /// <returns></returns> ! public override object Get( IDataReader rs, string name ) { ! return Convert.ToString( rs[ name ] ); } ! ! /// <summary></summary> ! public override System.Type ReturnedClass { ! get { return typeof( string ); } ! } ! ! /// <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; parm.Value = value; } ! /// <summary></summary> ! public override string Name { get { return "AnsiString"; } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public string ObjectToSQLString( object value ) { ! return "'" + ( string ) value + "'"; } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="xml"></param> ! /// <returns></returns> ! public object StringToObject( string xml ) { return xml; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="x"></param> ! /// <param name="y"></param> ! /// <returns></returns> ! public override bool Equals( object x, object y ) { ! return ObjectUtils.Equals( x, y ); } ! /// <summary></summary> ! public override int GetHashCode() { ! return base.GetHashCode(); } + /// <summary> + /// + /// </summary> + /// <param name="value"></param> + /// <returns></returns> + public override string ToXML( object value ) + { + return ( string ) value; + } + } + } \ No newline at end of file Index: AbstractType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/AbstractType.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AbstractType.cs 20 Aug 2004 17:39:01 -0000 1.9 --- AbstractType.cs 31 Dec 2004 23:50:57 -0000 1.10 *************** *** 1,10 **** using System; using System.Data; - using NHibernate.Engine; using NHibernate.SqlTypes; ! ! namespace NHibernate.Type { /// <summary> --- 1,8 ---- using System; using System.Data; using NHibernate.Engine; using NHibernate.SqlTypes; ! namespace NHibernate.Type { /// <summary> *************** *** 13,17 **** /// </summary> [Serializable] ! public abstract class AbstractType : IType { /// <summary> --- 11,15 ---- /// </summary> [Serializable] ! public abstract class AbstractType : IType { /// <summary> *************** *** 19,49 **** /// </summary> /// <value>false - by default an <see cref="AbstractType"/> is not an <see cref="IAssociationType"/>.</value> ! public virtual bool IsAssociationType { ! get { return false; } } ! /// <summary> /// Gets a value indicating if the <see cref="AbstractType"/> is a <see cref="PersistentCollectionType"/>. /// </summary> /// <value>false - by default an <see cref="AbstractType"/> is not a <see cref="PersistentCollectionType"/>.</value> ! public virtual bool IsPersistentCollectionType { get { return false; } } ! /// <summary> /// Gets a value indicating if the <see cref="AbstractType"/> is an <see cref="IAbstractComponentType"/>. /// </summary> /// <value>false - by default an <see cref="AbstractType"/> is not an <see cref="IAbstractComponentType"/>.</value> ! public virtual bool IsComponentType { ! get { return false; } } ! /// <summary> /// Gets a value indicating if the <see cref="AbstractType"/> is a <see cref="EntityType"/>. /// </summary> /// <value>false - by default an <see cref="AbstractType"/> is not a <see cref="EntityType"/>.</value> ! public virtual bool IsEntityType { get { return false; } --- 17,48 ---- /// </summary> /// <value>false - by default an <see cref="AbstractType"/> is not an <see cref="IAssociationType"/>.</value> ! public virtual bool IsAssociationType ! { ! get { return false; } } ! /// <summary> /// Gets a value indicating if the <see cref="AbstractType"/> is a <see cref="PersistentCollectionType"/>. /// </summary> /// <value>false - by default an <see cref="AbstractType"/> is not a <see cref="PersistentCollectionType"/>.</value> ! public virtual bool IsPersistentCollectionType { get { return false; } } ! /// <summary> /// Gets a value indicating if the <see cref="AbstractType"/> is an <see cref="IAbstractComponentType"/>. /// </summary> /// <value>false - by default an <see cref="AbstractType"/> is not an <see cref="IAbstractComponentType"/>.</value> ! public virtual bool IsComponentType { ! get { return false; } } ! /// <summary> /// Gets a value indicating if the <see cref="AbstractType"/> is a <see cref="EntityType"/>. /// </summary> /// <value>false - by default an <see cref="AbstractType"/> is not a <see cref="EntityType"/>.</value> ! public virtual bool IsEntityType { get { return false; } *************** *** 54,64 **** /// </summary> /// <value>false - by default an <see cref="AbstractType"/> is not a "object" type.</value> ! public virtual bool IsObjectType { ! get ! { ! return false; ! } } /// <summary> /// Disassembles the object into a cacheable representation. --- 53,61 ---- /// </summary> /// <value>false - by default an <see cref="AbstractType"/> is not a "object" type.</value> ! public virtual bool IsObjectType { ! get { return false; } } + /// <summary> /// Disassembles the object into a cacheable representation. *************** *** 70,83 **** /// This method calls DeepCopy if the value is not null. /// </remarks> ! public virtual object Disassemble(object value, ISessionImplementor session) { ! if (value==null) { return null; } ! else { ! return DeepCopy(value); } } ! /// <summary> /// Reconstructs the object from its cached "disassembled" state. --- 67,82 ---- /// This method calls DeepCopy if the value is not null. /// </remarks> ! public virtual object Disassemble( object value, ISessionImplementor session ) { ! if( value == null ) ! { return null; } ! else ! { ! return DeepCopy( value ); } } ! /// <summary> /// Reconstructs the object from its cached "disassembled" state. *************** *** 90,104 **** /// This method calls DeepCopy if the value is not null. /// </remarks> ! public virtual object Assemble(object cached, ISessionImplementor session, object owner) { ! if ( cached==null ) { return null; } ! else { ! return DeepCopy(cached); } } ! ! /// <summary> /// Should the parent be considered dirty, given both the old and current --- 89,105 ---- /// This method calls DeepCopy if the value is not null. /// </remarks> ! public virtual object Assemble( object cached, ISessionImplementor session, object owner ) { ! if( cached == null ) ! { return null; } ! else ! { ! return DeepCopy( cached ); } } ! ! /// <summary> /// Should the parent be considered dirty, given both the old and current *************** *** 110,118 **** /// <returns>true if the field is dirty</returns> /// <remarks>This method uses <c>IType.Equals(object, object)</c> to determine the value of IsDirty.</remarks> ! public virtual bool IsDirty(object old, object current, ISessionImplementor session) { ! return !Equals(old, current); } ! /// <summary> --- 111,119 ---- /// <returns>true if the field is dirty</returns> /// <remarks>This method uses <c>IType.Equals(object, object)</c> to determine the value of IsDirty.</remarks> ! public virtual bool IsDirty( object old, object current, ISessionImplementor session ) { ! return !Equals( old, current ); } ! /// <summary> *************** *** 132,140 **** /// to Hydrate this <see cref="AbstractType"/>. /// </remarks> ! public virtual object Hydrate(IDataReader rs, string[] names, ISessionImplementor session, object owner) { ! return NullSafeGet(rs, names, session, owner); } ! /// <summary> /// Maps identifiers to Entities or Collections. --- 133,141 ---- /// to Hydrate this <see cref="AbstractType"/>. /// </remarks> ! public virtual object Hydrate( IDataReader rs, string[ ] names, ISessionImplementor session, object owner ) { ! return NullSafeGet( rs, names, session, owner ); } ! /// <summary> /// Maps identifiers to Entities or Collections. *************** *** 147,179 **** /// There is nothing done in this method other than return the value parameter passed in. /// </remarks> ! public virtual object ResolveIdentifier(object value, ISessionImplementor session, object owner) { return value; } ! /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="M:IType.DeepCopy"]/*' /// /> ! public abstract object DeepCopy(object val); /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="M:IType.SqlTypes"]/*' /// /> ! public abstract SqlType[] SqlTypes(IMapping mapping); /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="M:IType.GetColumnSpan"]/*' /// /> ! public abstract int GetColumnSpan(IMapping mapping); /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="M:IType.Equals"]/*' /// /> ! public abstract new bool Equals(object x, object y); //We need "new" because object.Equal is not marked as virtual. Is it correct? /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="P:IType.IsMutable"]/*' /// /> ! public abstract bool IsMutable {get;} /// <include file='IType.cs.xmldoc' --- 148,180 ---- /// There is nothing done in this method other than return the value parameter passed in. /// </remarks> ! public virtual object ResolveIdentifier( object value, ISessionImplementor session, object owner ) { return value; } ! /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="M:IType.DeepCopy"]/*' /// /> ! public abstract object DeepCopy( object val ); /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="M:IType.SqlTypes"]/*' /// /> ! public abstract SqlType[ ] SqlTypes( IMapping mapping ); /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="M:IType.GetColumnSpan"]/*' /// /> ! public abstract int GetColumnSpan( IMapping mapping ); /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="M:IType.Equals"]/*' /// /> ! new public abstract bool Equals( object x, object y ); //We need "new" because object.Equal is not marked as virtual. Is it correct? Or because this is *abstract* so we're not really overriding it? /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="P:IType.IsMutable"]/*' /// /> ! public abstract bool IsMutable { get; } /// <include file='IType.cs.xmldoc' *************** *** 190,204 **** /// path='//members[@type="IType"]/member[@name="M:IType.NullSafeGet(IDataReader, string[], ISessionImplementor, object)"]/*' /// /> ! public abstract object NullSafeGet(IDataReader rs, string[] names, ISessionImplementor session, object owner); /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="M:IType.NullSafeGet(IDataReader, string, ISessionImplementor, object)"]/*' /// /> ! public abstract object NullSafeGet(IDataReader rs, string name, ISessionImplementor session, Object owner); ! /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="M:IType.NullSafeSet"]/*' /// /> ! public abstract void NullSafeSet(IDbCommand st, object value, int index, ISessionImplementor session); /// <include file='IType.cs.xmldoc' --- 191,205 ---- /// path='//members[@type="IType"]/member[@name="M:IType.NullSafeGet(IDataReader, string[], ISessionImplementor, object)"]/*' /// /> ! public abstract object NullSafeGet( IDataReader rs, string[ ] names, ISessionImplementor session, object owner ); /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="M:IType.NullSafeGet(IDataReader, string, ISessionImplementor, object)"]/*' /// /> ! public abstract object NullSafeGet( IDataReader rs, string name, ISessionImplementor session, Object owner ); ! /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="M:IType.NullSafeSet"]/*' /// /> ! public abstract void NullSafeSet( IDbCommand st, object value, int index, ISessionImplementor session ); /// <include file='IType.cs.xmldoc' *************** *** 210,214 **** /// path='//members[@type="IType"]/member[@name="M:IType.ToXML"]/*' /// /> ! public abstract string ToXML(object value, ISessionFactoryImplementor factory); } } \ No newline at end of file --- 211,215 ---- /// path='//members[@type="IType"]/member[@name="M:IType.ToXML"]/*' /// /> ! public abstract string ToXML( object value, ISessionFactoryImplementor factory ); } } \ No newline at end of file Index: BinaryBlobType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/BinaryBlobType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BinaryBlobType.cs 25 Aug 2004 03:52:21 -0000 1.1 --- BinaryBlobType.cs 31 Dec 2004 23:50:57 -0000 1.2 *************** *** 1,5 **** - using System; - using System.Data; - using NHibernate.SqlTypes; --- 1,2 ---- *************** *** 16,32 **** public class BinaryBlobType : BinaryType { ! internal BinaryBlobType() : base( new BinaryBlobSqlType() ) { } ! internal BinaryBlobType(BinarySqlType sqlType) : base(sqlType) { } public override string Name { ! get {return "BinaryBlob"; } } } ! } --- 13,35 ---- public class BinaryBlobType : BinaryType { ! /// <summary></summary> ! internal BinaryBlobType() : base( new BinaryBlobSqlType() ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlType"></param> ! internal BinaryBlobType( BinarySqlType sqlType ) : base( sqlType ) { } + /// <summary></summary> public override string Name { ! get { return "BinaryBlob"; } } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:41:49
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12128 Modified Files: ITransactionFactory.cs Transaction.cs TransactionFactory.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: ITransactionFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction/ITransactionFactory.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ITransactionFactory.cs 20 Feb 2003 15:57:12 -0000 1.1 --- ITransactionFactory.cs 31 Dec 2004 22:41:39 -0000 1.2 *************** *** 1,20 **** - using System; using System.Collections; using NHibernate.Engine; - namespace NHibernate.Transaction { /// <summary> /// An abstract factory for <c>ITransaction</c> instances. (NHibernate note: do we need this??) /// </summary> ! public interface ITransactionFactory { /// <summary> /// Begin a transaction and return the associated <c>ITransaction</c> instance /// </summary> ! ITransaction BeginTransaction(ISessionImplementor session); /// <summary> /// Configure from the given properties /// </summary> ! void Configure(IDictionary props); } ! } --- 1,23 ---- using System.Collections; using NHibernate.Engine; + namespace NHibernate.Transaction + { /// <summary> /// An abstract factory for <c>ITransaction</c> instances. (NHibernate note: do we need this??) /// </summary> ! public interface ITransactionFactory ! { /// <summary> /// Begin a transaction and return the associated <c>ITransaction</c> instance /// </summary> ! /// <param name="session"></param> ! ITransaction BeginTransaction( ISessionImplementor session ); /// <summary> /// Configure from the given properties /// </summary> ! /// <param name="props"></param> ! void Configure( IDictionary props ); } ! } \ No newline at end of file Index: Transaction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction/Transaction.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Transaction.cs 5 Dec 2004 18:42:16 -0000 1.6 --- Transaction.cs 31 Dec 2004 22:41:39 -0000 1.7 *************** *** 1,7 **** using System; using System.Data; ! using NHibernate.Engine; ! namespace NHibernate.Transaction { /// <summary> --- 1,8 ---- using System; using System.Data; ! using log4net; using NHibernate.Engine; ! ! namespace NHibernate.Transaction { /// <summary> *************** *** 13,19 **** /// for JDBC Transactions or JTA Transactions. /// </remarks> ! public class Transaction : ITransaction { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Transaction)); private ISessionImplementor session; private IDbTransaction trans; --- 14,20 ---- /// for JDBC Transactions or JTA Transactions. /// </remarks> ! public class Transaction : ITransaction { ! private static readonly ILog log = LogManager.GetLogger( typeof( Transaction ) ); private ISessionImplementor session; private IDbTransaction trans; *************** *** 22,39 **** private bool rolledBack; ! public Transaction(ISessionImplementor session) { this.session = session; } ! public void Enlist(IDbCommand command) { ! if( trans==null ) { ! if( log.IsWarnEnabled ) { ! if( command.Transaction!=null ) { ! log.Warn("set a nonnull IDbCommand.Transaction to null because the Session had no Transaction"); } } --- 23,48 ---- private bool rolledBack; ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! public Transaction( ISessionImplementor session ) { this.session = session; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="command"></param> ! public void Enlist( IDbCommand command ) { ! if( trans == null ) { ! if( log.IsWarnEnabled ) { ! if( command.Transaction != null ) { ! log.Warn( "set a nonnull IDbCommand.Transaction to null because the Session had no Transaction" ); } } *************** *** 42,82 **** return; } ! else { ! if( log.IsWarnEnabled ) { // got into here because the command was being initialized and had a null Transaction - probably // don't need to be confused by that - just a normal part of initialization... ! if( command.Transaction!=null && command.Transaction!=trans ) { ! log.Warn("The IDbCommand had a different Transaction than the Session. This can occur when " + ! "Disconnecting and Reconnecting Sessions because the PreparedCommand Cache is Session specific."); } } ! ! command.Transaction = trans; } } ! public void Begin() { ! log.Debug("begin"); ! try { IsolationLevel isolation = session.Factory.Isolation; ! if( isolation==IsolationLevel.Unspecified ) { trans = session.Connection.BeginTransaction(); } ! else { trans = session.Connection.BeginTransaction( isolation ); } ! } ! catch( Exception e ) { ! log.Error("Begin transaction failed", e); ! throw new TransactionException("Begin failed with SQL exception", e); } --- 51,92 ---- return; } ! else { ! if( log.IsWarnEnabled ) { // got into here because the command was being initialized and had a null Transaction - probably // don't need to be confused by that - just a normal part of initialization... ! if( command.Transaction != null && command.Transaction != trans ) { ! log.Warn( "The IDbCommand had a different Transaction than the Session. This can occur when " + ! "Disconnecting and Reconnecting Sessions because the PreparedCommand Cache is Session specific." ); } } ! ! command.Transaction = trans; } } ! /// <summary></summary> ! public void Begin() { ! log.Debug( "begin" ); ! try { IsolationLevel isolation = session.Factory.Isolation; ! if( isolation == IsolationLevel.Unspecified ) { trans = session.Connection.BeginTransaction(); } ! else { trans = session.Connection.BeginTransaction( isolation ); } ! } ! catch( Exception e ) { ! log.Error( "Begin transaction failed", e ); ! throw new TransactionException( "Begin failed with SQL exception", e ); } *************** *** 84,114 **** } ! public void Commit() { ! if (!begun) { ! throw new TransactionException("Transaction not successfully started"); } ! log.Debug("commit"); ! try { ! if( session.FlushMode!=FlushMode.Never ) { session.Flush(); } ! try { trans.Commit(); committed = true; ! } ! catch( Exception e ) { ! log.Error("Commit failed", e); ! throw new TransactionException("Commit failed with SQL exception", e); } ! } ! finally { session.AfterTransactionCompletion(); --- 94,125 ---- } ! /// <summary></summary> ! public void Commit() { ! if( !begun ) { ! throw new TransactionException( "Transaction not successfully started" ); } ! log.Debug( "commit" ); ! try { ! if( session.FlushMode != FlushMode.Never ) { session.Flush(); } ! try { trans.Commit(); committed = true; ! } ! catch( Exception e ) { ! log.Error( "Commit failed", e ); ! throw new TransactionException( "Commit failed with SQL exception", e ); } ! } ! finally { session.AfterTransactionCompletion(); *************** *** 116,138 **** } ! public void Rollback() { ! if (!begun) { ! throw new TransactionException("Transaction not successfully started"); } ! log.Debug("rollback"); ! try { trans.Rollback(); rolledBack = true; ! } ! catch( Exception e ) { ! log.Error("Rollback failed", e); ! throw new TransactionException("Rollback failed with SQL Exception", e); ! } ! finally { session.AfterTransactionCompletion(); --- 127,150 ---- } ! /// <summary></summary> ! public void Rollback() { ! if( !begun ) { ! throw new TransactionException( "Transaction not successfully started" ); } ! log.Debug( "rollback" ); ! try { trans.Rollback(); rolledBack = true; ! } ! catch( Exception e ) { ! log.Error( "Rollback failed", e ); ! throw new TransactionException( "Rollback failed with SQL Exception", e ); ! } ! finally { session.AfterTransactionCompletion(); *************** *** 140,149 **** } ! public bool WasRolledBack { get { return rolledBack; } } ! public bool WasCommitted { get { return committed; } --- 152,163 ---- } ! /// <summary></summary> ! public bool WasRolledBack { get { return rolledBack; } } ! /// <summary></summary> ! public bool WasCommitted { get { return committed; } *************** *** 151,153 **** } ! } --- 165,167 ---- } ! } \ No newline at end of file Index: TransactionFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction/TransactionFactory.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TransactionFactory.cs 20 Feb 2003 15:57:13 -0000 1.1 --- TransactionFactory.cs 31 Dec 2004 22:41:39 -0000 1.2 *************** *** 1,21 **** - using System; - using System.Data; using System.Collections; using NHibernate.Engine; ! namespace NHibernate.Transaction { ! /// <summary> /// Summary description for TransactionFactory. /// </summary> ! public class TransactionFactory : ITransactionFactory { ! ! public ITransaction BeginTransaction(ISessionImplementor session) { ! Transaction tx = new Transaction(session); tx.Begin(); return tx; } ! public void Configure(IDictionary props) {} } ! } --- 1,31 ---- using System.Collections; using NHibernate.Engine; ! namespace NHibernate.Transaction ! { /// <summary> /// Summary description for TransactionFactory. /// </summary> ! public class TransactionFactory : ITransactionFactory ! { ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <returns></returns> ! public ITransaction BeginTransaction( ISessionImplementor session ) ! { ! Transaction tx = new Transaction( session ); tx.Begin(); return tx; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="props"></param> ! public void Configure( IDictionary props ) ! { ! } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:40:04
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Tool/hbm2ddl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11770 Modified Files: AdoColumn.cs AdoTable.cs SchemaExport.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: AdoColumn.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Tool/hbm2ddl/AdoColumn.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AdoColumn.cs 21 Mar 2003 19:49:11 -0000 1.1 --- AdoColumn.cs 31 Dec 2004 22:39:53 -0000 1.2 *************** *** 1,15 **** - using System; using System.Data; ! namespace NHibernate.Tool.hbm2ddl { ! ! public class AdoColumn { private string name; private System.Type type; private int columnSize; private bool isNullable; - ! public AdoColumn(DataColumn column) { name = column.ColumnName; type = column.DataType; --- 1,20 ---- using System.Data; ! namespace NHibernate.Tool.hbm2ddl ! { ! /// <summary></summary> ! public class AdoColumn ! { private string name; private System.Type type; private int columnSize; private bool isNullable; ! /// <summary> ! /// ! /// </summary> ! /// <param name="column"></param> ! public AdoColumn( DataColumn column ) ! { name = column.ColumnName; type = column.DataType; *************** *** 18,41 **** } ! public string Name { get { return name; } } ! public System.Type Type { get { return type; } } ! public int ColumnSize { get { return columnSize; } } ! public bool IsNullable { get { return isNullable; } } ! public override string ToString() { return name; } ! public override int GetHashCode() { return name.GetHashCode(); } } ! } --- 23,74 ---- } ! /// <summary></summary> ! public string Name ! { get { return name; } } ! ! /// <summary></summary> ! public System.Type Type ! { get { return type; } } ! ! /// <summary></summary> ! public int ColumnSize ! { get { return columnSize; } } ! ! /// <summary></summary> ! public bool IsNullable ! { get { return isNullable; } } ! /// <summary></summary> ! public override string ToString() ! { return name; } ! /// <summary></summary> ! public override int GetHashCode() ! { return name.GetHashCode(); } + + /// <summary> + /// + /// </summary> + /// <param name="obj"></param> + /// <returns></returns> + public override bool Equals( object obj ) + { + if( this == obj ) return true; + AdoColumn c = obj as AdoColumn; + if( c == null || !c.Equals( this ) ) return false; + return c.Name == this.name; + } } ! } \ No newline at end of file Index: AdoTable.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Tool/hbm2ddl/AdoTable.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AdoTable.cs 21 Mar 2003 19:49:12 -0000 1.1 --- AdoTable.cs 31 Dec 2004 22:39:53 -0000 1.2 *************** *** 1,22 **** - using System; - using System.Data; using System.Collections; ! namespace NHibernate.Tool.hbm2ddl { ! ! public class AdoTable { ! private string name; private IDictionary columns = new Hashtable(); ! private IDictionary foreignKeys = new Hashtable(); ! private IDictionary indexes = new Hashtable(); ! ! public AdoTable(DataTable table) { name = table.TableName; ! foreach(DataColumn column in table.Columns) { ! columns.Add( column.ColumnName, new AdoColumn(column) ); } } ! public ICollection Columns { get { return columns.Values; } } --- 1,31 ---- using System.Collections; + using System.Data; ! namespace NHibernate.Tool.hbm2ddl ! { ! /// <summary></summary> ! public class AdoTable ! { ! private string name; // not used !?! private IDictionary columns = new Hashtable(); ! // private IDictionary foreignKeys = new Hashtable(); ! // private IDictionary indexes = new Hashtable(); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="table"></param> ! public AdoTable( DataTable table ) ! { name = table.TableName; ! foreach( DataColumn column in table.Columns ) ! { ! columns.Add( column.ColumnName, new AdoColumn( column ) ); } } ! /// <summary></summary> ! public ICollection Columns ! { get { return columns.Values; } } *************** *** 24,26 **** } ! } --- 33,35 ---- } ! } \ No newline at end of file Index: SchemaExport.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaExport.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SchemaExport.cs 27 Dec 2004 02:27:28 -0000 1.12 --- SchemaExport.cs 31 Dec 2004 22:39:53 -0000 1.13 *************** *** 4,15 **** using System.IO; using System.Text; - using NHibernate.Cfg; using NHibernate.Connection; - using NHibernate.Dialect; using NHibernate.Util; ! ! namespace NHibernate.Tool.hbm2ddl { /// <summary> --- 4,12 ---- using System.IO; using System.Text; using NHibernate.Cfg; using NHibernate.Connection; using NHibernate.Util; ! namespace NHibernate.Tool.hbm2ddl { /// <summary> *************** *** 20,27 **** /// used when a dll can not be directly used. /// </remarks> ! public class SchemaExport { ! private string[] dropSQL; ! private string[] createSQL; private IDictionary connectionProperties; private string outputFile = null; --- 17,24 ---- /// used when a dll can not be directly used. /// </remarks> ! public class SchemaExport { ! private string[ ] dropSQL; ! private string[ ] createSQL; private IDictionary connectionProperties; private string outputFile = null; *************** *** 33,37 **** /// </summary> /// <param name="cfg">The NHibernate Configuration to generate the schema from.</param> ! public SchemaExport(Configuration cfg) : this(cfg, cfg.Properties) { } --- 30,34 ---- /// </summary> /// <param name="cfg">The NHibernate Configuration to generate the schema from.</param> ! public SchemaExport( Configuration cfg ) : this( cfg, cfg.Properties ) { } *************** *** 43,52 **** /// <param name="cfg">The NHibernate Configuration to generate the schema from.</param> /// <param name="connectionProperties">The Properties to use when connecting to the Database.</param> ! public SchemaExport(Configuration cfg, IDictionary connectionProperties) { this.connectionProperties = connectionProperties; ! dialect = Dialect.Dialect.GetDialect(connectionProperties); ! dropSQL = cfg.GenerateDropSchemaScript(dialect); ! createSQL = cfg.GenerateSchemaCreationScript(dialect); } --- 40,49 ---- /// <param name="cfg">The NHibernate Configuration to generate the schema from.</param> /// <param name="connectionProperties">The Properties to use when connecting to the Database.</param> ! public SchemaExport( Configuration cfg, IDictionary connectionProperties ) { this.connectionProperties = connectionProperties; ! dialect = Dialect.Dialect.GetDialect( connectionProperties ); ! dropSQL = cfg.GenerateDropSchemaScript( dialect ); ! createSQL = cfg.GenerateSchemaCreationScript( dialect ); } *************** *** 56,65 **** /// <param name="filename">The name of the file to output the ddl to.</param> /// <returns>The SchemaExport object.</returns> ! public SchemaExport SetOutputFile(string filename) { outputFile = filename; return this; } ! /// <summary> /// Set the end of statement delimiter --- 53,62 ---- /// <param name="filename">The name of the file to output the ddl to.</param> /// <returns>The SchemaExport object.</returns> ! public SchemaExport SetOutputFile( string filename ) { outputFile = filename; return this; } ! /// <summary> /// Set the end of statement delimiter *************** *** 67,75 **** /// <param name="delimiter">The end of statement delimiter.</param> /// <returns>The SchemaExport object.</returns> ! public SchemaExport SetDelimiter(string delimiter) { this.delimiter = delimiter; return this; } /// <summary> /// Run the schema creation script --- 64,73 ---- /// <param name="delimiter">The end of statement delimiter.</param> /// <returns>The SchemaExport object.</returns> ! public SchemaExport SetDelimiter( string delimiter ) { this.delimiter = delimiter; return this; } + /// <summary> /// Run the schema creation script *************** *** 81,87 **** /// the justDrop parameter to false and the format parameter to true. /// </remarks> ! public void Create(bool script, bool export) { ! Execute(script, export, false, true); } --- 79,85 ---- /// the justDrop parameter to false and the format parameter to true. /// </remarks> ! public void Create( bool script, bool export ) { ! Execute( script, export, false, true ); } *************** *** 95,101 **** /// the justDrop and format parameter to true. /// </remarks> ! public void Drop(bool script, bool export) { ! Execute(script, export, true, true); } --- 93,99 ---- /// the justDrop and format parameter to true. /// </remarks> ! public void Drop( bool script, bool export ) { ! Execute( script, export, true, true ); } *************** *** 110,116 **** /// This method allows for both the drop and create ddl script to be executed. /// </remarks> ! public void Execute(bool script, bool export, bool justDrop, bool format) { ! IDbConnection connection = null; StreamWriter fileOutput = null; IConnectionProvider connectionProvider = null; --- 108,114 ---- /// This method allows for both the drop and create ddl script to be executed. /// </remarks> ! public void Execute( bool script, bool export, bool justDrop, bool format ) { ! IDbConnection connection = null; StreamWriter fileOutput = null; IConnectionProvider connectionProvider = null; *************** *** 118,240 **** IDictionary props = new Hashtable(); ! foreach(DictionaryEntry de in dialect.DefaultProperties) { ! props[de.Key] = de.Value ; } ! ! if (connectionProperties!=null) { ! foreach(DictionaryEntry de in connectionProperties) { ! props[de.Key] = de.Value; } } ! ! try { ! if (outputFile!=null) { ! fileOutput = new StreamWriter(outputFile); } ! if (export) { ! connectionProvider = ConnectionProviderFactory.NewConnectionProvider(props); connection = connectionProvider.GetConnection(); statement = connection.CreateCommand(); } ! for (int i=0; i<dropSQL.Length; i++) { ! try { string formatted; ! if(format) { ! formatted = Format( dropSQL[i] ); } ! else { ! formatted = dropSQL[i]; } ! if (delimiter!=null) formatted += delimiter; ! if (script) Console.WriteLine(formatted); ! if (outputFile!=null) fileOutput.WriteLine( formatted ); ! if (export) { ! statement.CommandText = dropSQL[i]; statement.CommandType = CommandType.Text; statement.ExecuteNonQuery(); } ! } ! catch(Exception e) { ! if (!script) Console.WriteLine( dropSQL[i] ); Console.WriteLine( "Unsuccessful: " + e.Message ); } } ! if (!justDrop) { ! for (int j=0; j<createSQL.Length; j++) { ! try { string formatted; ! if(format) { ! formatted = Format( createSQL[j] ); } ! else { ! formatted = createSQL[j]; } ! if (delimiter!=null) formatted += delimiter; ! if (script) Console.WriteLine(formatted); ! if (outputFile!=null) fileOutput.WriteLine( formatted ); ! if (export) { ! statement.CommandText = createSQL[j]; statement.CommandType = CommandType.Text; statement.ExecuteNonQuery(); } ! } ! catch(Exception e) { ! if (!script) Console.WriteLine( createSQL[j] ); Console.WriteLine( "Unsuccessful: " + e.Message ); } } } ! ! } ! catch (Exception e) { ! Console.Write(e.StackTrace); throw new HibernateException( e.Message, e ); ! } ! finally { ! try { ! if (statement!=null) statement.Dispose(); ! if (connection!=null) { ! connectionProvider.CloseConnection(connection); connectionProvider.Close(); } ! } ! catch(Exception e) { Console.Error.WriteLine( "Could not close connection: " + e.Message ); } ! if (fileOutput!=null) { ! try { fileOutput.Close(); ! } ! catch (Exception ioe) { Console.Error.WriteLine( "Error closing output file " + outputFile + ": " + ioe.Message ); --- 116,265 ---- IDictionary props = new Hashtable(); ! foreach( DictionaryEntry de in dialect.DefaultProperties ) { ! props[ de.Key ] = de.Value; } ! ! if( connectionProperties != null ) { ! foreach( DictionaryEntry de in connectionProperties ) { ! props[ de.Key ] = de.Value; } } ! ! try { ! if( outputFile != null ) { ! fileOutput = new StreamWriter( outputFile ); } ! if( export ) { ! connectionProvider = ConnectionProviderFactory.NewConnectionProvider( props ); connection = connectionProvider.GetConnection(); statement = connection.CreateCommand(); } ! for( int i = 0; i < dropSQL.Length; i++ ) { ! try { string formatted; ! if( format ) { ! formatted = Format( dropSQL[ i ] ); } ! else { ! formatted = dropSQL[ i ]; } ! if( delimiter != null ) { ! formatted += delimiter; ! } ! if( script ) ! { ! Console.WriteLine( formatted ); ! } ! if( outputFile != null ) ! { ! fileOutput.WriteLine( formatted ); ! } ! if( export ) ! { ! statement.CommandText = dropSQL[ i ]; statement.CommandType = CommandType.Text; statement.ExecuteNonQuery(); } ! } ! catch( Exception e ) { ! if( !script ) ! { ! Console.WriteLine( dropSQL[ i ] ); ! } Console.WriteLine( "Unsuccessful: " + e.Message ); } } ! if( !justDrop ) { ! for( int j = 0; j < createSQL.Length; j++ ) { ! try { string formatted; ! if( format ) { ! formatted = Format( createSQL[ j ] ); } ! else { ! formatted = createSQL[ j ]; } ! if( delimiter != null ) { ! formatted += delimiter; ! } ! if( script ) ! { ! Console.WriteLine( formatted ); ! } ! if( outputFile != null ) ! { ! fileOutput.WriteLine( formatted ); ! } ! if( export ) ! { ! statement.CommandText = createSQL[ j ]; statement.CommandType = CommandType.Text; statement.ExecuteNonQuery(); } ! } ! catch( Exception e ) { ! if( !script ) ! { ! Console.WriteLine( createSQL[ j ] ); ! } Console.WriteLine( "Unsuccessful: " + e.Message ); } } } ! ! } ! catch( Exception e ) { ! Console.Write( e.StackTrace ); throw new HibernateException( e.Message, e ); ! } ! finally { ! try { ! if( statement != null ) { ! statement.Dispose(); ! } ! if( connection != null ) ! { ! connectionProvider.CloseConnection( connection ); connectionProvider.Close(); } ! } ! catch( Exception e ) { Console.Error.WriteLine( "Could not close connection: " + e.Message ); } ! if( fileOutput != null ) { ! try { fileOutput.Close(); ! } ! catch( Exception ioe ) { Console.Error.WriteLine( "Error closing output file " + outputFile + ": " + ioe.Message ); *************** *** 266,272 **** /// </list> /// </remarks> ! private static string Format(string sql) { ! if ( sql.IndexOf("\"") > 0 || sql.IndexOf("'") > 0) { return sql; --- 291,297 ---- /// </list> /// </remarks> ! private static string Format( string sql ) { ! if( sql.IndexOf( "\"" ) > 0 || sql.IndexOf( "'" ) > 0 ) { return sql; *************** *** 275,304 **** string formatted; ! if ( sql.ToLower().StartsWith("create table") ) { ! StringBuilder result = new StringBuilder(60); ! StringTokenizer tokens = new StringTokenizer( sql, "(,)", true); int depth = 0; ! foreach(string tok in tokens) { ! if ( StringHelper.ClosedParen.Equals(tok) ) { depth--; ! if (depth==0) result.Append("\n"); } ! result.Append(tok); ! if ( StringHelper.Comma.Equals(tok) && depth==1 ) result.Append("\n "); ! if ( StringHelper.OpenParen.Equals(tok) ) { depth++; ! if ( depth==1 ) result.Append("\n "); } } formatted = result.ToString(); ! } ! else { formatted = sql; --- 300,338 ---- string formatted; ! if( sql.ToLower().StartsWith( "create table" ) ) { ! StringBuilder result = new StringBuilder( 60 ); ! StringTokenizer tokens = new StringTokenizer( sql, "(,)", true ); int depth = 0; ! foreach( string tok in tokens ) { ! if( StringHelper.ClosedParen.Equals( tok ) ) { depth--; ! if( depth == 0 ) ! { ! result.Append( "\n" ); ! } } ! result.Append( tok ); ! if( StringHelper.Comma.Equals( tok ) && depth == 1 ) ! { ! result.Append( "\n " ); ! } ! if( StringHelper.OpenParen.Equals( tok ) ) { depth++; ! if( depth == 1 ) ! { ! result.Append( "\n " ); ! } } } formatted = result.ToString(); ! } ! else { formatted = sql; *************** *** 306,310 **** return formatted; ! } } ! } --- 340,344 ---- return formatted; ! } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:33:03
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10591 Modified Files: SqlType.cs SqlTypeFactory.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: SqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/SqlType.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SqlType.cs 11 Dec 2004 16:28:28 -0000 1.5 --- SqlType.cs 31 Dec 2004 22:32:52 -0000 1.6 *************** *** 2,7 **** using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// This is the base class that adds information to the <see cref="DbType" /> --- 2,7 ---- using System.Data; ! namespace NHibernate.SqlTypes ! { /// <summary> /// This is the base class that adds information to the <see cref="DbType" /> *************** *** 29,39 **** private bool _lengthDefined = false; private bool _precisionDefined = false; ! ! protected SqlType(DbType dbType) { _dbType = dbType; } ! protected SqlType(DbType dbType, int length) { _dbType = dbType; --- 29,48 ---- private bool _lengthDefined = false; private bool _precisionDefined = false; ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="dbType"></param> ! protected SqlType( DbType dbType ) { _dbType = dbType; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dbType"></param> ! /// <param name="length"></param> ! protected SqlType( DbType dbType, int length ) { _dbType = dbType; *************** *** 42,46 **** } ! protected SqlType(DbType dbType, byte precision, byte scale) { _dbType = dbType; --- 51,61 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dbType"></param> ! /// <param name="precision"></param> ! /// <param name="scale"></param> ! protected SqlType( DbType dbType, byte precision, byte scale ) { _dbType = dbType; *************** *** 50,98 **** } ! public DbType DbType { ! get { return _dbType;} } ! public int Length { ! get { return _length;} } ! public byte Precision { ! get { return _precision;} } ! public byte Scale { ! get { return _scale;} } ! public bool LengthDefined { ! get { return _lengthDefined;} } ! public bool PrecisionDefined { ! get { return _precisionDefined;} } #region System.Object Members ! public override int GetHashCode() { int hashCode = 0; ! if( LengthDefined ) { hashCode = ( DbType.GetHashCode()/2 ) + ( Length.GetHashCode()/2 ); } ! else if( PrecisionDefined) { hashCode = ( DbType.GetHashCode()/3 ) + ( Precision.GetHashCode()/3 ) + ( Scale.GetHashCode()/3 ); } ! else { hashCode = DbType.GetHashCode(); --- 65,120 ---- } ! /// <summary></summary> ! public DbType DbType { ! get { return _dbType; } } ! /// <summary></summary> ! public int Length { ! get { return _length; } } ! /// <summary></summary> ! public byte Precision { ! get { return _precision; } } ! /// <summary></summary> ! public byte Scale { ! get { return _scale; } } ! /// <summary></summary> ! public bool LengthDefined { ! get { return _lengthDefined; } } ! /// <summary></summary> ! public bool PrecisionDefined { ! get { return _precisionDefined; } } #region System.Object Members ! /// <summary></summary> ! public override int GetHashCode() { int hashCode = 0; ! if( LengthDefined ) { hashCode = ( DbType.GetHashCode()/2 ) + ( Length.GetHashCode()/2 ); } ! else if( PrecisionDefined ) { hashCode = ( DbType.GetHashCode()/3 ) + ( Precision.GetHashCode()/3 ) + ( Scale.GetHashCode()/3 ); } ! else { hashCode = DbType.GetHashCode(); *************** *** 102,116 **** } ! public override bool Equals(object obj) { bool equals = false; SqlType rhsSqlType; ! // Step1: Perform an equals test ! if( obj==this ) return true; // Step 2: Instance of check rhsSqlType = obj as SqlType; ! if( rhsSqlType==null ) return false; //Step 3: Check each important field --- 124,149 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="obj"></param> ! /// <returns></returns> ! public override bool Equals( object obj ) { bool equals = false; SqlType rhsSqlType; ! // Step1: Perform an equals test ! if( obj == this ) ! { ! return true; ! } // Step 2: Instance of check rhsSqlType = obj as SqlType; ! if( rhsSqlType == null ) ! { ! return false; ! } //Step 3: Check each important field *************** *** 118,131 **** if( LengthDefined ) { ! equals = ( DbType.Equals( rhsSqlType.DbType ) ) ! && ( Length==rhsSqlType.Length ); } ! else if( PrecisionDefined ) { equals = ( DbType.Equals( rhsSqlType.DbType ) ) ! && ( Precision==rhsSqlType.Precision ) ! && ( Scale==rhsSqlType.Scale ); } ! else { equals = ( DbType.Equals( rhsSqlType.DbType ) ); --- 151,164 ---- if( LengthDefined ) { ! equals = ( DbType.Equals( rhsSqlType.DbType ) ) ! && ( Length == rhsSqlType.Length ); } ! else if( PrecisionDefined ) { equals = ( DbType.Equals( rhsSqlType.DbType ) ) ! && ( Precision == rhsSqlType.Precision ) ! && ( Scale == rhsSqlType.Scale ); } ! else { equals = ( DbType.Equals( rhsSqlType.DbType ) ); *************** *** 137,141 **** #endregion - } ! } --- 170,173 ---- #endregion } ! } \ No newline at end of file Index: SqlTypeFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/SqlTypeFactory.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SqlTypeFactory.cs 22 Nov 2004 03:52:18 -0000 1.8 --- SqlTypeFactory.cs 31 Dec 2004 22:32:52 -0000 1.9 *************** *** 2,6 **** using System.Collections; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Collections; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 8,17 **** /// </summary> [Serializable] ! public sealed class SqlTypeFactory { // key = typeof(sqlType).Name : ie - BinarySqlType(l), BooleanSqlType, DecimalSqlType(p,s) // value = SqlType ! private static Hashtable sqlTypes = Hashtable.Synchronized(new Hashtable(41)); ! private static object lockObject = new object(); private SqlTypeFactory() --- 8,17 ---- /// </summary> [Serializable] ! public sealed class SqlTypeFactory { // key = typeof(sqlType).Name : ie - BinarySqlType(l), BooleanSqlType, DecimalSqlType(p,s) // value = SqlType ! private static Hashtable sqlTypes = Hashtable.Synchronized( new Hashtable( 41 ) ); ! private static object lockObject = new object(); // not used !?! private SqlTypeFactory() *************** *** 19,42 **** } ! public static AnsiStringSqlType GetAnsiString(int length) { ! string key = GetKeyForLengthBased(typeof(AnsiStringSqlType).Name, length); ! AnsiStringSqlType returnSqlType = (AnsiStringSqlType) sqlTypes[key]; ! if(returnSqlType == null) { ! returnSqlType = new AnsiStringSqlType(length); ! sqlTypes.Add(key, returnSqlType); } return returnSqlType; } ! public static AnsiStringFixedLengthSqlType GetAnsiStringFixedLength(int length) { ! string key = GetKeyForLengthBased(typeof(AnsiStringFixedLengthSqlType).Name, length); ! AnsiStringFixedLengthSqlType returnSqlType = (AnsiStringFixedLengthSqlType) sqlTypes[key]; ! if(returnSqlType == null) { ! returnSqlType = new AnsiStringFixedLengthSqlType(length); ! sqlTypes.Add(key, returnSqlType); } return returnSqlType; --- 19,52 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="length"></param> ! /// <returns></returns> ! public static AnsiStringSqlType GetAnsiString( int length ) { ! string key = GetKeyForLengthBased( typeof( AnsiStringSqlType ).Name, length ); ! AnsiStringSqlType returnSqlType = ( AnsiStringSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { ! returnSqlType = new AnsiStringSqlType( length ); ! sqlTypes.Add( key, returnSqlType ); } return returnSqlType; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="length"></param> ! /// <returns></returns> ! public static AnsiStringFixedLengthSqlType GetAnsiStringFixedLength( int length ) { ! string key = GetKeyForLengthBased( typeof( AnsiStringFixedLengthSqlType ).Name, length ); ! AnsiStringFixedLengthSqlType returnSqlType = ( AnsiStringFixedLengthSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { ! returnSqlType = new AnsiStringFixedLengthSqlType( length ); ! sqlTypes.Add( key, returnSqlType ); } return returnSqlType; *************** *** 44,281 **** } ! public static BinarySqlType GetBinary(int length) { ! string key = GetKeyForLengthBased(typeof(BinarySqlType).Name, length); ! BinarySqlType returnSqlType = (BinarySqlType)sqlTypes[key]; ! if(returnSqlType==null) { ! returnSqlType = new BinarySqlType(length); ! sqlTypes.Add(key, returnSqlType); } return returnSqlType; ! } ! public static BooleanSqlType GetBoolean() { ! string key = typeof(BooleanSqlType).Name; ! BooleanSqlType returnSqlType = (BooleanSqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new BooleanSqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } - - public static ByteSqlType GetByte() - { ! string key = typeof(ByteSqlType).Name; ! ByteSqlType returnSqlType = (ByteSqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new ByteSqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static CurrencySqlType GetCurrency() { ! string key = typeof(CurrencySqlType).Name; ! ! CurrencySqlType returnSqlType = (CurrencySqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new CurrencySqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } public static DateSqlType GetDate() { ! string key = typeof(DateSqlType).Name; ! ! DateSqlType returnSqlType = (DateSqlType)sqlTypes[key]; ! if(returnSqlType==null) { ! returnSqlType = new DateSqlType(); ! sqlTypes.Add(key, returnSqlType); ! } ! ! return returnSqlType; ! } ! public static DateTimeSqlType GetDateTime() { ! string key = typeof(DateTimeSqlType).Name; ! ! DateTimeSqlType returnSqlType = (DateTimeSqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new DateTimeSqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static DecimalSqlType GetDecimal(byte precision, byte scale) { ! string key = GetKeyForPrecisionScaleBased(typeof(DecimalSqlType).Name, precision, scale); ! ! DecimalSqlType returnSqlType = (DecimalSqlType)sqlTypes[key]; ! if(returnSqlType==null) { ! returnSqlType = new DecimalSqlType(precision, scale); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static DoubleSqlType GetDouble() { ! string key = typeof(DoubleSqlType).Name; ! ! DoubleSqlType returnSqlType = (DoubleSqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new DoubleSqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static GuidSqlType GetGuid() { ! string key = typeof(GuidSqlType).Name; ! ! GuidSqlType returnSqlType = (GuidSqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new GuidSqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static Int16SqlType GetInt16() { ! string key = typeof(Int16SqlType).Name; ! ! Int16SqlType returnSqlType = (Int16SqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new Int16SqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static Int32SqlType GetInt32() { ! string key = typeof(Int32SqlType).Name; ! ! Int32SqlType returnSqlType = (Int32SqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new Int32SqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static Int64SqlType GetInt64() { ! string key = typeof(Int64SqlType).Name; ! ! Int64SqlType returnSqlType = (Int64SqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new Int64SqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static SingleSqlType GetSingle() { ! string key = typeof(SingleSqlType).Name; ! ! SingleSqlType returnSqlType = (SingleSqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new SingleSqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static StringSqlType GetString(int length) { ! string key = GetKeyForLengthBased(typeof(StringSqlType).Name, length); ! ! StringSqlType returnSqlType = (StringSqlType)sqlTypes[key]; ! if(returnSqlType==null) { ! returnSqlType = new StringSqlType(length); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static StringFixedLengthSqlType GetStringFixedLength(int length) { ! string key = GetKeyForLengthBased(typeof(StringFixedLengthSqlType).Name, length); ! ! StringFixedLengthSqlType returnSqlType = (StringFixedLengthSqlType)sqlTypes[key]; ! if(returnSqlType==null) { ! returnSqlType = new StringFixedLengthSqlType(length); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! public static TimeSqlType GetTime() { ! string key = typeof(TimeSqlType).Name; ! ! TimeSqlType returnSqlType = (TimeSqlType)sqlTypes[key]; ! if(returnSqlType==null) { returnSqlType = new TimeSqlType(); ! sqlTypes.Add(key, returnSqlType); } ! return returnSqlType; } ! private static string GetKeyForLengthBased(string name, int length) { return name + "(" + length + ")"; } ! private static string GetKeyForPrecisionScaleBased(string name, byte precision, byte scale) { return name + "(" + precision + ", " + scale + ")"; } } ! } --- 54,322 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="length"></param> ! /// <returns></returns> ! public static BinarySqlType GetBinary( int length ) { ! string key = GetKeyForLengthBased( typeof( BinarySqlType ).Name, length ); ! BinarySqlType returnSqlType = ( BinarySqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { ! returnSqlType = new BinarySqlType( length ); ! sqlTypes.Add( key, returnSqlType ); } return returnSqlType; ! } ! /// <summary></summary> ! public static BooleanSqlType GetBoolean() { ! string key = typeof( BooleanSqlType ).Name; ! BooleanSqlType returnSqlType = ( BooleanSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new BooleanSqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static ByteSqlType GetByte() ! { ! string key = typeof( ByteSqlType ).Name; ! ByteSqlType returnSqlType = ( ByteSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new ByteSqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static CurrencySqlType GetCurrency() { ! string key = typeof( CurrencySqlType ).Name; ! ! CurrencySqlType returnSqlType = ( CurrencySqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new CurrencySqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } + /// <summary></summary> public static DateSqlType GetDate() { ! string key = typeof( DateSqlType ).Name; ! ! DateSqlType returnSqlType = ( DateSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { ! returnSqlType = new DateSqlType(); ! sqlTypes.Add( key, returnSqlType ); ! } + return returnSqlType; + } ! /// <summary></summary> ! public static DateTimeSqlType GetDateTime() { ! string key = typeof( DateTimeSqlType ).Name; ! ! DateTimeSqlType returnSqlType = ( DateTimeSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new DateTimeSqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="precision"></param> ! /// <param name="scale"></param> ! /// <returns></returns> ! public static DecimalSqlType GetDecimal( byte precision, byte scale ) { ! string key = GetKeyForPrecisionScaleBased( typeof( DecimalSqlType ).Name, precision, scale ); ! ! DecimalSqlType returnSqlType = ( DecimalSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { ! returnSqlType = new DecimalSqlType( precision, scale ); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static DoubleSqlType GetDouble() { ! string key = typeof( DoubleSqlType ).Name; ! ! DoubleSqlType returnSqlType = ( DoubleSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new DoubleSqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static GuidSqlType GetGuid() { ! string key = typeof( GuidSqlType ).Name; ! ! GuidSqlType returnSqlType = ( GuidSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new GuidSqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static Int16SqlType GetInt16() { ! string key = typeof( Int16SqlType ).Name; ! ! Int16SqlType returnSqlType = ( Int16SqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new Int16SqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static Int32SqlType GetInt32() { ! string key = typeof( Int32SqlType ).Name; ! ! Int32SqlType returnSqlType = ( Int32SqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new Int32SqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static Int64SqlType GetInt64() { ! string key = typeof( Int64SqlType ).Name; ! ! Int64SqlType returnSqlType = ( Int64SqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new Int64SqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static SingleSqlType GetSingle() { ! string key = typeof( SingleSqlType ).Name; ! ! SingleSqlType returnSqlType = ( SingleSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new SingleSqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="length"></param> ! /// <returns></returns> ! public static StringSqlType GetString( int length ) { ! string key = GetKeyForLengthBased( typeof( StringSqlType ).Name, length ); ! ! StringSqlType returnSqlType = ( StringSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { ! returnSqlType = new StringSqlType( length ); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="length"></param> ! /// <returns></returns> ! public static StringFixedLengthSqlType GetStringFixedLength( int length ) { ! string key = GetKeyForLengthBased( typeof( StringFixedLengthSqlType ).Name, length ); ! ! StringFixedLengthSqlType returnSqlType = ( StringFixedLengthSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { ! returnSqlType = new StringFixedLengthSqlType( length ); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! /// <summary></summary> ! public static TimeSqlType GetTime() { ! string key = typeof( TimeSqlType ).Name; ! ! TimeSqlType returnSqlType = ( TimeSqlType ) sqlTypes[ key ]; ! if( returnSqlType == null ) { returnSqlType = new TimeSqlType(); ! sqlTypes.Add( key, returnSqlType ); } ! return returnSqlType; } ! private static string GetKeyForLengthBased( string name, int length ) { return name + "(" + length + ")"; } ! private static string GetKeyForPrecisionScaleBased( string name, byte precision, byte scale ) { return name + "(" + precision + ", " + scale + ")"; } } ! } \ No newline at end of file |
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10547 Modified Files: SByteSqlType.cs SingleSqlType.cs StringClobSqlType.cs StringFixedLengthSqlType.cs StringSqlType.cs TimeSqlType.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: SingleSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/SingleSqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SingleSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 --- SingleSqlType.cs 31 Dec 2004 22:32:41 -0000 1.5 *************** *** 2,6 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 12,23 **** /// </remarks> [Serializable] ! public class SingleSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="SingleSqlType"/> class. /// </summary> ! public SingleSqlType() : base(DbType.Single) { } } ! } --- 12,23 ---- /// </remarks> [Serializable] ! public class SingleSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="SingleSqlType"/> class. /// </summary> ! public SingleSqlType() : base( DbType.Single ) { } } ! } \ No newline at end of file Index: StringClobSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/StringClobSqlType.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StringClobSqlType.cs 11 Dec 2004 16:28:28 -0000 1.2 --- StringClobSqlType.cs 31 Dec 2004 22:32:41 -0000 1.3 *************** *** 22,32 **** /// </remarks> [Serializable] ! public class StringClobSqlType : StringSqlType { - /// <summary> /// Initializes a new instance of the <see cref="StringClobSqlType"/> class. /// </summary> ! public StringClobSqlType() : base() { } --- 22,31 ---- /// </remarks> [Serializable] ! public class StringClobSqlType : StringSqlType { /// <summary> /// Initializes a new instance of the <see cref="StringClobSqlType"/> class. /// </summary> ! public StringClobSqlType() : base() { } *************** *** 36,40 **** /// </summary> /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> ! public StringClobSqlType(int length) : base(length) { } --- 35,39 ---- /// </summary> /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> ! public StringClobSqlType( int length ) : base( length ) { } Index: StringFixedLengthSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/StringFixedLengthSqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** StringFixedLengthSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 --- StringFixedLengthSqlType.cs 31 Dec 2004 22:32:41 -0000 1.5 *************** *** 2,6 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 14,35 **** /// </remarks> [Serializable] ! public class StringFixedLengthSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="StringFixedLengthSqlType"/> class. /// </summary> ! public StringFixedLengthSqlType() : base(DbType.StringFixedLength) ! { } ! /// <summary> /// Initializes a new instance of the <see cref="StringFixedLengthSqlType"/> class. /// </summary> /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> ! public StringFixedLengthSqlType(int length) : base(DbType.StringFixedLength, length) ! { } } ! } ! --- 14,34 ---- /// </remarks> [Serializable] ! public class StringFixedLengthSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="StringFixedLengthSqlType"/> class. /// </summary> ! public StringFixedLengthSqlType() : base( DbType.StringFixedLength ) ! { } ! /// <summary> /// Initializes a new instance of the <see cref="StringFixedLengthSqlType"/> class. /// </summary> /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> ! public StringFixedLengthSqlType( int length ) : base( DbType.StringFixedLength, length ) ! { } } ! } \ No newline at end of file Index: TimeSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/TimeSqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TimeSqlType.cs 11 Dec 2004 16:28:28 -0000 1.3 --- TimeSqlType.cs 31 Dec 2004 22:32:41 -0000 1.4 *************** *** 17,21 **** /// Initializes a new instance of the <see cref="TimeSqlType"/> class. /// </summary> ! public TimeSqlType() : base(DbType.Time) { } --- 17,21 ---- /// Initializes a new instance of the <see cref="TimeSqlType"/> class. /// </summary> ! public TimeSqlType() : base( DbType.Time ) { } Index: SByteSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/SByteSqlType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SByteSqlType.cs 11 Dec 2004 16:28:28 -0000 1.1 --- SByteSqlType.cs 31 Dec 2004 22:32:41 -0000 1.2 *************** *** 17,24 **** /// Initializes a new instance of the <see cref="SByteSqlType"/> class. /// </summary> ! public SByteSqlType() : base(DbType.SByte) { } } ! } ! --- 17,23 ---- /// Initializes a new instance of the <see cref="SByteSqlType"/> class. /// </summary> ! public SByteSqlType() : base( DbType.SByte ) { } } ! } \ No newline at end of file Index: StringSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/StringSqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** StringSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 --- StringSqlType.cs 31 Dec 2004 22:32:41 -0000 1.5 *************** *** 2,6 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 14,24 **** /// </remarks> [Serializable] ! public class StringSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="StringSqlType"/> class. /// </summary> ! public StringSqlType() : base(DbType.String) ! { } --- 14,24 ---- /// </remarks> [Serializable] ! public class StringSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="StringSqlType"/> class. /// </summary> ! public StringSqlType() : base( DbType.String ) ! { } *************** *** 27,33 **** /// </summary> /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> ! public StringSqlType(int length) : base(DbType.String, length) ! { } } ! } --- 27,33 ---- /// </summary> /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> ! public StringSqlType( int length ) : base( DbType.String, length ) ! { } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:32:39
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10504 Modified Files: DoubleSqlType.cs GuidSqlType.cs Int16SqlType.cs Int32SqlType.cs Int64SqlType.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: Int64SqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/Int64SqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Int64SqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 --- Int64SqlType.cs 31 Dec 2004 22:32:27 -0000 1.5 *************** *** 2,6 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 17,21 **** /// Initializes a new instance of the <see cref="Int64SqlType"/> class. /// </summary> ! public Int64SqlType(): base(DbType.Int64) { } --- 17,21 ---- /// Initializes a new instance of the <see cref="Int64SqlType"/> class. /// </summary> ! public Int64SqlType() : base( DbType.Int64 ) { } Index: GuidSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/GuidSqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GuidSqlType.cs 11 Dec 2004 16:28:28 -0000 1.3 --- GuidSqlType.cs 31 Dec 2004 22:32:27 -0000 1.4 *************** *** 17,23 **** /// Initializes a new instance of the <see cref="GuidSqlType"/> class. /// </summary> ! public GuidSqlType() : base(DbType.Guid) { } } ! } --- 17,23 ---- /// Initializes a new instance of the <see cref="GuidSqlType"/> class. /// </summary> ! public GuidSqlType() : base( DbType.Guid ) { } } ! } \ No newline at end of file Index: DoubleSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/DoubleSqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DoubleSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 --- DoubleSqlType.cs 31 Dec 2004 22:32:27 -0000 1.5 *************** *** 2,6 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 12,21 **** /// </remarks> [Serializable] ! public class DoubleSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="DoubleSqlType"/> class. /// </summary> ! public DoubleSqlType() : base(DbType.Double) { } --- 12,21 ---- /// </remarks> [Serializable] ! public class DoubleSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="DoubleSqlType"/> class. /// </summary> ! public DoubleSqlType() : base( DbType.Double ) { } Index: Int16SqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/Int16SqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Int16SqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 --- Int16SqlType.cs 31 Dec 2004 22:32:27 -0000 1.5 *************** *** 2,6 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 17,23 **** /// Initializes a new instance of the <see cref="Int16SqlType"/> class. /// </summary> ! public Int16SqlType(): base(DbType.Int16) { } } ! } --- 17,23 ---- /// Initializes a new instance of the <see cref="Int16SqlType"/> class. /// </summary> ! public Int16SqlType() : base( DbType.Int16 ) { } } ! } \ No newline at end of file Index: Int32SqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/Int32SqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Int32SqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 --- Int32SqlType.cs 31 Dec 2004 22:32:27 -0000 1.5 *************** *** 2,6 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 17,24 **** /// Initializes a new instance of the <see cref="Int32SqlType"/> class. /// </summary> ! public Int32SqlType(): base(DbType.Int32) { } } ! } --- 17,24 ---- /// Initializes a new instance of the <see cref="Int32SqlType"/> class. /// </summary> ! public Int32SqlType() : base( DbType.Int32 ) { } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:32:24
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10436 Modified Files: ByteSqlType.cs CurrencySqlType.cs DateSqlType.cs DateTimeSqlType.cs DecimalSqlType.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: DecimalSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/DecimalSqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DecimalSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 --- DecimalSqlType.cs 31 Dec 2004 22:32:11 -0000 1.5 *************** *** 2,6 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 15,28 **** /// </remarks> [Serializable] ! public class DecimalSqlType : SqlType { - /// <summary> /// Initializes a new instance of the <see cref="DecimalSqlType"/> class. /// </summary> ! public DecimalSqlType() : base(DbType.Decimal) { } ! /// <summary> /// Initializes a new instance of the <see cref="DecimalSqlType"/> class. --- 15,27 ---- /// </remarks> [Serializable] ! public class DecimalSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="DecimalSqlType"/> class. /// </summary> ! public DecimalSqlType() : base( DbType.Decimal ) { } ! /// <summary> /// Initializes a new instance of the <see cref="DecimalSqlType"/> class. *************** *** 30,36 **** /// <param name="precision">The precision of the Decimal the <see cref="IDbDataParameter"/> should hold.</param> /// <param name="scale">The scale of the Decimal the <see cref="IDbDataParameter"/> should hold.</param> ! public DecimalSqlType(byte precision, byte scale) : base(DbType.Decimal, precision, scale) { } } ! } --- 29,35 ---- /// <param name="precision">The precision of the Decimal the <see cref="IDbDataParameter"/> should hold.</param> /// <param name="scale">The scale of the Decimal the <see cref="IDbDataParameter"/> should hold.</param> ! public DecimalSqlType( byte precision, byte scale ) : base( DbType.Decimal, precision, scale ) { } } ! } \ No newline at end of file Index: DateTimeSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/DateTimeSqlType.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DateTimeSqlType.cs 11 Dec 2004 16:28:28 -0000 1.5 --- DateTimeSqlType.cs 31 Dec 2004 22:32:11 -0000 1.6 *************** *** 2,6 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 12,23 **** /// </remarks> [Serializable] ! public class DateTimeSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="DateTimeSqlType"/> class. /// </summary> ! public DateTimeSqlType() : base(DbType.DateTime) { } } ! } --- 12,23 ---- /// </remarks> [Serializable] ! public class DateTimeSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="DateTimeSqlType"/> class. /// </summary> ! public DateTimeSqlType() : base( DbType.DateTime ) { } } ! } \ No newline at end of file Index: ByteSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/ByteSqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ByteSqlType.cs 11 Dec 2004 16:28:28 -0000 1.3 --- ByteSqlType.cs 31 Dec 2004 22:32:11 -0000 1.4 *************** *** 2,6 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 17,23 **** /// Initializes a new instance of the <see cref="ByteSqlType"/> class. /// </summary> ! public ByteSqlType() : base(DbType.Byte) { } } ! } --- 17,23 ---- /// Initializes a new instance of the <see cref="ByteSqlType"/> class. /// </summary> ! public ByteSqlType() : base( DbType.Byte ) { } } ! } \ No newline at end of file Index: DateSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/DateSqlType.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DateSqlType.cs 11 Dec 2004 16:28:28 -0000 1.3 --- DateSqlType.cs 31 Dec 2004 22:32:11 -0000 1.4 *************** *** 17,23 **** /// Initializes a new instance of the <see cref="DateSqlType"/> class. /// </summary> ! public DateSqlType() : base(DbType.Date) { } } ! } --- 17,23 ---- /// Initializes a new instance of the <see cref="DateSqlType"/> class. /// </summary> ! public DateSqlType() : base( DbType.Date ) { } } ! } \ No newline at end of file Index: CurrencySqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/CurrencySqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CurrencySqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 --- CurrencySqlType.cs 31 Dec 2004 22:32:11 -0000 1.5 *************** *** 2,6 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 17,23 **** /// Initializes a new instance of the <see cref="CurrencySqlType"/> class. /// </summary> ! public CurrencySqlType() : base(DbType.Currency) { } } ! } --- 17,23 ---- /// Initializes a new instance of the <see cref="CurrencySqlType"/> class. /// </summary> ! public CurrencySqlType() : base( DbType.Currency ) { } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:32:11
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10334 Modified Files: AnsiStringFixedLengthSqlType.cs AnsiStringSqlType.cs BinaryBlobSqlType.cs BinarySqlType.cs BooleanSqlType.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: AnsiStringFixedLengthSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/AnsiStringFixedLengthSqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AnsiStringFixedLengthSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 --- AnsiStringFixedLengthSqlType.cs 31 Dec 2004 22:31:48 -0000 1.5 *************** *** 2,6 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 14,23 **** /// </remarks> [Serializable] ! public class AnsiStringFixedLengthSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="AnsiStringFixedLengthSqlType"/> class. /// </summary> ! public AnsiStringFixedLengthSqlType() : base(DbType.AnsiStringFixedLength) { } --- 14,23 ---- /// </remarks> [Serializable] ! public class AnsiStringFixedLengthSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="AnsiStringFixedLengthSqlType"/> class. /// </summary> ! public AnsiStringFixedLengthSqlType() : base( DbType.AnsiStringFixedLength ) { } *************** *** 27,34 **** /// </summary> /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> ! public AnsiStringFixedLengthSqlType(int length) : base(DbType.AnsiStringFixedLength, length) ! { } } ! } --- 27,34 ---- /// </summary> /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> ! public AnsiStringFixedLengthSqlType( int length ) : base( DbType.AnsiStringFixedLength, length ) ! { } } ! } \ No newline at end of file Index: BooleanSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/BooleanSqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BooleanSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 --- BooleanSqlType.cs 31 Dec 2004 22:31:48 -0000 1.5 *************** *** 2,6 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 12,23 **** /// </remarks> [Serializable] ! public class BooleanSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="BooleanSqlType"/> class. /// </summary> ! public BooleanSqlType() : base(DbType.Boolean) { } } ! } --- 12,23 ---- /// </remarks> [Serializable] ! public class BooleanSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="BooleanSqlType"/> class. /// </summary> ! public BooleanSqlType() : base( DbType.Boolean ) { } } ! } \ No newline at end of file Index: BinarySqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/BinarySqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BinarySqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 --- BinarySqlType.cs 31 Dec 2004 22:31:48 -0000 1.5 *************** *** 14,34 **** /// </remarks> [Serializable] ! public class BinarySqlType : SqlType { - /// <summary> /// Initializes a new instance of the <see cref="BinarySqlType"/> class. /// </summary> ! public BinarySqlType() : base (DbType.Binary) { } ! /// <summary> /// Initializes a new instance of the <see cref="BinarySqlType"/> class. /// </summary> /// <param name="length">The length of the binary data the <see cref="IDbDataParameter"/> should hold</param> ! public BinarySqlType(int length) : base (DbType.Binary, length) { } } ! } --- 14,33 ---- /// </remarks> [Serializable] ! public class BinarySqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="BinarySqlType"/> class. /// </summary> ! public BinarySqlType() : base( DbType.Binary ) { } ! /// <summary> /// Initializes a new instance of the <see cref="BinarySqlType"/> class. /// </summary> /// <param name="length">The length of the binary data the <see cref="IDbDataParameter"/> should hold</param> ! public BinarySqlType( int length ) : base( DbType.Binary, length ) { } } ! } \ No newline at end of file Index: AnsiStringSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/AnsiStringSqlType.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AnsiStringSqlType.cs 11 Dec 2004 16:28:28 -0000 1.4 --- AnsiStringSqlType.cs 31 Dec 2004 22:31:48 -0000 1.5 *************** *** 2,6 **** using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> --- 2,6 ---- using System.Data; ! namespace NHibernate.SqlTypes { /// <summary> *************** *** 14,23 **** /// </remarks> [Serializable] ! public class AnsiStringSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="AnsiStringSqlType"/> class. /// </summary> ! public AnsiStringSqlType() : base(DbType.AnsiString) { } --- 14,23 ---- /// </remarks> [Serializable] ! public class AnsiStringSqlType : SqlType { /// <summary> /// Initializes a new instance of the <see cref="AnsiStringSqlType"/> class. /// </summary> ! public AnsiStringSqlType() : base( DbType.AnsiString ) { } *************** *** 27,33 **** /// </summary> /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> ! public AnsiStringSqlType(int length) : base(DbType.AnsiString, length) ! { } } ! } --- 27,33 ---- /// </summary> /// <param name="length">The length of the string the <see cref="IDbDataParameter"/> should hold.</param> ! public AnsiStringSqlType( int length ) : base( DbType.AnsiString, length ) ! { } } ! } \ No newline at end of file Index: BinaryBlobSqlType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlTypes/BinaryBlobSqlType.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BinaryBlobSqlType.cs 11 Dec 2004 16:28:28 -0000 1.2 --- BinaryBlobSqlType.cs 31 Dec 2004 22:31:48 -0000 1.3 *************** *** 22,40 **** /// </remarks> [Serializable] ! public class BinaryBlobSqlType : BinarySqlType { - /// <summary> /// Initializes a new instance of the <see cref="BinaryBlobSqlType"/> class. /// </summary> ! public BinaryBlobSqlType() : base() { } ! /// <summary> /// Initializes a new instance of the <see cref="BinaryBlobSqlType"/> class. /// </summary> /// <param name="length">The length of the binary data the <see cref="IDbDataParameter"/> should hold</param> ! public BinaryBlobSqlType(int length) : base(length) { } --- 22,39 ---- /// </remarks> [Serializable] ! public class BinaryBlobSqlType : BinarySqlType { /// <summary> /// Initializes a new instance of the <see cref="BinaryBlobSqlType"/> class. /// </summary> ! public BinaryBlobSqlType() : base() { } ! /// <summary> /// Initializes a new instance of the <see cref="BinaryBlobSqlType"/> class. /// </summary> /// <param name="length">The length of the binary data the <see cref="IDbDataParameter"/> should hold</param> ! public BinaryBlobSqlType( int length ) : base( length ) { } |
From: Kevin W. <kev...@us...> - 2004-12-31 22:26:16
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9366 Modified Files: SqlUpdateBuilder.cs Template.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: SqlUpdateBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlUpdateBuilder.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SqlUpdateBuilder.cs 22 Nov 2004 03:56:08 -0000 1.4 --- SqlUpdateBuilder.cs 31 Dec 2004 22:25:58 -0000 1.5 *************** *** 1,12 **** - using System; using System.Collections; ! using System.Text; ! ! using NHibernate.Connection; ! using NHibernate.Dialect; using NHibernate.Engine; - using NHibernate.Util; using NHibernate.Type; ! namespace NHibernate.SqlCommand --- 1,7 ---- using System.Collections; ! using log4net; using NHibernate.Engine; using NHibernate.Type; ! using NHibernate.Util; namespace NHibernate.SqlCommand *************** *** 15,37 **** /// A class that builds an <c>UPDATE</c> sql statement. /// </summary> ! public class SqlUpdateBuilder: SqlBaseBuilder, ISqlStringBuilder { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(SqlUpdateBuilder) ); ! ! string tableName; ! IList columnNames = new ArrayList(); // name of the column ! IList columnValues = new ArrayList(); //string or a Parameter ! int identityFragmentIndex = -1; ! int versionFragmentIndex = -1; ! IList whereStrings = new ArrayList(); ! public SqlUpdateBuilder(ISessionFactoryImplementor factory) : base(factory) { } ! public SqlUpdateBuilder SetTableName(string tableName) { this.tableName = tableName; --- 10,41 ---- /// A class that builds an <c>UPDATE</c> sql statement. /// </summary> ! public class SqlUpdateBuilder : SqlBaseBuilder, ISqlStringBuilder { ! private static readonly ILog log = LogManager.GetLogger( typeof( SqlUpdateBuilder ) ); ! private string tableName; ! private IList columnNames = new ArrayList(); // name of the column ! private IList columnValues = new ArrayList(); //string or a Parameter ! private int identityFragmentIndex = -1; // not used !?! ! private int versionFragmentIndex = -1; // not used !?! ! private IList whereStrings = new ArrayList(); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="factory"></param> ! public SqlUpdateBuilder( ISessionFactoryImplementor factory ) : base( factory ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <returns></returns> ! public SqlUpdateBuilder SetTableName( string tableName ) { this.tableName = tableName; *************** *** 39,43 **** } - /// <summary> --- 43,46 ---- *************** *** 48,54 **** /// <param name="literalType">The NHibernateType to use to convert the value to a sql string.</param> /// <returns>The SqlUpdateBuilder.</returns> ! public SqlUpdateBuilder AddColumn(string columnName, object val, ILiteralType literalType) { ! return AddColumn(columnName, literalType.ObjectToSQLString(val)); } --- 51,57 ---- /// <param name="literalType">The NHibernateType to use to convert the value to a sql string.</param> /// <returns>The SqlUpdateBuilder.</returns> ! public SqlUpdateBuilder AddColumn( string columnName, object val, ILiteralType literalType ) { ! return AddColumn( columnName, literalType.ObjectToSQLString( val ) ); } *************** *** 60,69 **** /// <param name="val">A valid sql string to set as the value of the column.</param> /// <returns>The SqlUpdateBuilder.</returns> ! public SqlUpdateBuilder AddColumn(string columnName, string val) { ! ! columnNames.Add(columnName); ! columnValues.Add(val); ! return this; } --- 63,71 ---- /// <param name="val">A valid sql string to set as the value of the column.</param> /// <returns>The SqlUpdateBuilder.</returns> ! public SqlUpdateBuilder AddColumn( string columnName, string val ) { ! columnNames.Add( columnName ); ! columnValues.Add( val ); ! return this; } *************** *** 75,86 **** /// <param name="val">A valid sql string to set as the value of the column.</param> /// <returns>The SqlUpdateBuilder.</returns> ! public SqlUpdateBuilder AddColumns(string[] columnName, string val) { ! ! for(int i = 0; i < columnName.Length; i++) { ! columnNames.Add(columnName[i]); ! columnValues.Add(val); } ! return this; } --- 77,88 ---- /// <param name="val">A valid sql string to set as the value of the column.</param> /// <returns>The SqlUpdateBuilder.</returns> ! public SqlUpdateBuilder AddColumns( string[ ] columnName, string val ) { ! for( int i = 0; i < columnName.Length; i++ ) ! { ! columnNames.Add( columnName[ i ] ); ! columnValues.Add( val ); } ! return this; } *************** *** 92,108 **** /// <param name="propertyType">The IType of the property.</param> /// <returns>The SqlUpdateBuilder.</returns> ! public SqlUpdateBuilder AddColumns(string[] columnNames, IType propertyType) { ! Parameter[] parameters = Parameter.GenerateParameters( Factory, columnNames, propertyType ); ! for(int i = 0; i < columnNames.Length; i++) { ! this.columnNames.Add(columnNames[i]); ! columnValues.Add(parameters[i]); } ! return this; } ! /// <summary> /// Sets the IdentityColumn for the <c>UPDATE</c> sql to use. --- 94,110 ---- /// <param name="propertyType">The IType of the property.</param> /// <returns>The SqlUpdateBuilder.</returns> ! public SqlUpdateBuilder AddColumns( string[ ] columnNames, IType propertyType ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, columnNames, propertyType ); ! for( int i = 0; i < columnNames.Length; i++ ) { ! this.columnNames.Add( columnNames[ i ] ); ! columnValues.Add( parameters[ i ] ); } ! return this; } ! /// <summary> /// Sets the IdentityColumn for the <c>UPDATE</c> sql to use. *************** *** 111,119 **** /// <param name="identityType">The IType of the Identity Property.</param> /// <returns>The SqlUpdateBuilder.</returns> ! public SqlUpdateBuilder SetIdentityColumn(string[] columnNames, IType identityType) { ! Parameter[] parameters = Parameter.GenerateParameters( Factory, columnNames, identityType ); ! identityFragmentIndex = whereStrings.Add(ToWhereString(columnNames, parameters)); return this; --- 113,121 ---- /// <param name="identityType">The IType of the Identity Property.</param> /// <returns>The SqlUpdateBuilder.</returns> ! public SqlUpdateBuilder SetIdentityColumn( string[ ] columnNames, IType identityType ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, columnNames, identityType ); ! identityFragmentIndex = whereStrings.Add( ToWhereString( columnNames, parameters ) ); return this; *************** *** 126,134 **** /// <param name="versionType">The IVersionType of the Version Property.</param> /// <returns>The SqlUpdateBuilder.</returns> ! public SqlUpdateBuilder SetVersionColumn(string[] columnNames, IVersionType versionType) { ! Parameter[] parameters = Parameter.GenerateParameters( Factory, columnNames, versionType ); ! versionFragmentIndex = whereStrings.Add(ToWhereString(columnNames, parameters)); return this; --- 128,136 ---- /// <param name="versionType">The IVersionType of the Version Property.</param> /// <returns>The SqlUpdateBuilder.</returns> ! public SqlUpdateBuilder SetVersionColumn( string[ ] columnNames, IVersionType versionType ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, columnNames, versionType ); ! versionFragmentIndex = whereStrings.Add( ToWhereString( columnNames, parameters ) ); return this; *************** *** 142,149 **** /// <param name="op">The operator to put between the column name and value.</param> /// <returns>The SqlUpdateBuilder</returns> ! public SqlUpdateBuilder AddWhereFragment(string[] columnNames, IType type, string op) { ! Parameter[] parameters = Parameter.GenerateParameters( Factory, columnNames, type ); ! whereStrings.Add(ToWhereString(columnNames, parameters, op)); return this; --- 144,151 ---- /// <param name="op">The operator to put between the column name and value.</param> /// <returns>The SqlUpdateBuilder</returns> ! public SqlUpdateBuilder AddWhereFragment( string[ ] columnNames, IType type, string op ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, columnNames, type ); ! whereStrings.Add( ToWhereString( columnNames, parameters, op ) ); return this; *************** *** 155,168 **** /// <param name="whereString">A well formed sql string with no parameters.</param> /// <returns>The SqlUpdateBuilder</returns> ! public SqlUpdateBuilder AddWhereFragment(string whereString) { ! whereStrings.Add( new SqlString(whereString) ); return this; } - #region ISqlStringBuilder Members ! public SqlString ToSqlString() { // 3 = "UPDATE", tableName, "SET" --- 157,170 ---- /// <param name="whereString">A well formed sql string with no parameters.</param> /// <returns>The SqlUpdateBuilder</returns> ! public SqlUpdateBuilder AddWhereFragment( string whereString ) { ! whereStrings.Add( new SqlString( whereString ) ); return this; } #region ISqlStringBuilder Members ! /// <summary></summary> ! public SqlString ToSqlString() { // 3 = "UPDATE", tableName, "SET" *************** *** 171,177 **** // will have a comma for all but the first column, and then for each column // will have a name, " = ", value so mulitply by 3 ! if( columnNames.Count > 0 ) { ! initialCapacity += (columnNames.Count - 1) + (columnNames.Count * 3); } // 1 = "WHERE" --- 173,179 ---- // will have a comma for all but the first column, and then for each column // will have a name, " = ", value so mulitply by 3 ! if( columnNames.Count > 0 ) { ! initialCapacity += ( columnNames.Count - 1 ) + ( columnNames.Count*3 ); } // 1 = "WHERE" *************** *** 179,188 **** // the "AND" before all but the first whereString ! if( whereStrings.Count > 0 ) { ! initialCapacity += (whereStrings.Count -1); ! for( int i=0; i <whereStrings.Count; i++ ) { ! initialCapacity += ((SqlString)whereStrings[i]).Count; } } --- 181,190 ---- // the "AND" before all but the first whereString ! if( whereStrings.Count > 0 ) { ! initialCapacity += ( whereStrings.Count - 1 ); ! for( int i = 0; i < whereStrings.Count; i++ ) { ! initialCapacity += ( ( SqlString ) whereStrings[ i ] ).Count; } } *************** *** 193,248 **** bool andNeeded = false; - - sqlBuilder.Add("UPDATE ") - .Add(tableName) - .Add(" SET "); ! for(int i = 0; i < columnNames.Count; i++) { ! if(commaNeeded) sqlBuilder.Add(StringHelper.CommaSpace); commaNeeded = true; ! string columnName = (string)columnNames[i]; ! object columnValue = columnValues[i]; - sqlBuilder.Add(columnName) - .Add(" = "); - Parameter param = columnValue as Parameter; ! if(param!=null) { ! sqlBuilder.Add(param); } ! else { ! sqlBuilder.Add((string)columnValue); } } - - sqlBuilder.Add(" WHERE "); ! foreach(SqlString whereString in whereStrings) { ! if(andNeeded) sqlBuilder.Add(" AND "); andNeeded = true; ! sqlBuilder.Add(whereString, null, null, null, false); } ! if(log.IsDebugEnabled) { ! if( initialCapacity < sqlBuilder.Count ) { ! log.Debug( "The initial capacity was set too low at: " + initialCapacity + " for the UpdateSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + tableName ); } ! else if( initialCapacity > 16 && ((float)initialCapacity/sqlBuilder.Count) > 1.2 ) { log.Debug( "The initial capacity was set too high at: " + initialCapacity + " for the UpdateSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + tableName); } } --- 195,256 ---- bool andNeeded = false; ! sqlBuilder.Add( "UPDATE " ) ! .Add( tableName ) ! .Add( " SET " ); ! ! for( int i = 0; i < columnNames.Count; i++ ) { ! if( commaNeeded ) ! { ! sqlBuilder.Add( StringHelper.CommaSpace ); ! } commaNeeded = true; ! string columnName = ( string ) columnNames[ i ]; ! object columnValue = columnValues[ i ]; ! ! sqlBuilder.Add( columnName ) ! .Add( " = " ); Parameter param = columnValue as Parameter; ! if( param != null ) { ! sqlBuilder.Add( param ); } ! else { ! sqlBuilder.Add( ( string ) columnValue ); } } ! sqlBuilder.Add( " WHERE " ); ! ! foreach( SqlString whereString in whereStrings ) { ! if( andNeeded ) ! { ! sqlBuilder.Add( " AND " ); ! } andNeeded = true; ! sqlBuilder.Add( whereString, null, null, null, false ); } ! if( log.IsDebugEnabled ) { ! if( initialCapacity < sqlBuilder.Count ) { ! log.Debug( "The initial capacity was set too low at: " + initialCapacity + " for the UpdateSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + tableName ); } ! else if( initialCapacity > 16 && ( ( float ) initialCapacity/sqlBuilder.Count ) > 1.2 ) { log.Debug( "The initial capacity was set too high at: " + initialCapacity + " for the UpdateSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + tableName ); } } *************** *** 253,255 **** #endregion } ! } --- 261,263 ---- #endregion } ! } \ No newline at end of file Index: Template.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/Template.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Template.cs 4 Dec 2004 22:41:30 -0000 1.10 --- Template.cs 31 Dec 2004 22:25:58 -0000 1.11 *************** *** 2,26 **** using System.Collections; using System.Text; - using Iesi.Collections; - - using NHibernate.Dialect; using NHibernate.Util; ! namespace NHibernate.SqlCommand { - /// <summary> /// Summary description for Template. /// </summary> ! public sealed class Template { public const string PlaceHolder = "$PlaceHolder"; ! private static ISet Keywords = new HashedSet(); ! private static ArrayList delimiterList = new ArrayList(13); private static string delimiters = null; ! static Template() { Keywords.Add( "and" ); --- 2,24 ---- using System.Collections; using System.Text; using Iesi.Collections; using NHibernate.Util; ! namespace NHibernate.SqlCommand { /// <summary> /// Summary description for Template. /// </summary> ! public sealed class Template { + /// <summary></summary> public const string PlaceHolder = "$PlaceHolder"; ! private static ISet Keywords = new HashedSet(); ! private static ArrayList delimiterList = new ArrayList( 13 ); private static string delimiters = null; ! /// <summary></summary> ! static Template() { Keywords.Add( "and" ); *************** *** 40,65 **** Keywords.Add( "by" ); ! delimiterList.Add(" "); ! delimiterList.Add("="); ! delimiterList.Add(">"); ! delimiterList.Add("<"); ! delimiterList.Add("!"); ! delimiterList.Add("+"); ! delimiterList.Add("-"); ! delimiterList.Add("*"); ! delimiterList.Add("/"); ! delimiterList.Add("("); ! delimiterList.Add(")"); ! delimiterList.Add("'"); ! delimiterList.Add(","); ! foreach(string delim in delimiterList) { ! delimiters += delim; } } ! private Template() { } --- 38,63 ---- Keywords.Add( "by" ); ! delimiterList.Add( " " ); ! delimiterList.Add( "=" ); ! delimiterList.Add( ">" ); ! delimiterList.Add( "<" ); ! delimiterList.Add( "!" ); ! delimiterList.Add( "+" ); ! delimiterList.Add( "-" ); ! delimiterList.Add( "*" ); ! delimiterList.Add( "/" ); ! delimiterList.Add( "(" ); ! delimiterList.Add( ")" ); ! delimiterList.Add( "'" ); ! delimiterList.Add( "," ); ! foreach( string delim in delimiterList ) { ! delimiters += delim; } } ! private Template() { } *************** *** 69,73 **** /// </summary> /// <param name="keyword">The Keyword to add.</param> ! public static void AddKeyword(string keyword) { Keywords.Add( keyword ); --- 67,71 ---- /// </summary> /// <param name="keyword">The Keyword to add.</param> ! public static void AddKeyword( string keyword ) { Keywords.Add( keyword ); *************** *** 78,90 **** /// </summary> /// <param name="delimiter">The delimiter to add.</param> ! public static void AddDelimiter(string delimiter) { ! if ( !delimiterList.Contains(delimiter) ) { ! delimiterList.Add(delimiter); ! delimiters += delimiter; } } ! /// <summary> /// Takes the where condition provided in the mapping attribute and iterpolates the alias. --- 76,88 ---- /// </summary> /// <param name="delimiter">The delimiter to add.</param> ! public static void AddDelimiter( string delimiter ) { ! if( !delimiterList.Contains( delimiter ) ) { ! delimiterList.Add( delimiter ); ! delimiters += delimiter; } } ! /// <summary> /// Takes the where condition provided in the mapping attribute and iterpolates the alias. *************** *** 93,103 **** /// <param name="dialect"></param> /// <returns></returns> ! public static string RenderWhereStringTemplate(string sqlWhereString, Dialect.Dialect dialect) { //TODO: make this a bit nicer. ! ! StringTokenizer tokens = new StringTokenizer(sqlWhereString, delimiters, true); ! ! StringBuilder result = new StringBuilder(sqlWhereString.Length + 10); bool quoted = false; --- 91,101 ---- /// <param name="dialect"></param> /// <returns></returns> ! public static string RenderWhereStringTemplate( string sqlWhereString, Dialect.Dialect dialect ) { //TODO: make this a bit nicer. ! ! StringTokenizer tokens = new StringTokenizer( sqlWhereString, delimiters, true ); ! ! StringBuilder result = new StringBuilder( sqlWhereString.Length + 10 ); bool quoted = false; *************** *** 107,159 **** IEnumerator tokensEnum = tokens.GetEnumerator(); bool hasMore = tokensEnum.MoveNext(); ! string nextToken = hasMore ? (string)tokensEnum.Current : null; ! while(hasMore) { string token = nextToken; hasMore = tokensEnum.MoveNext(); ! nextToken = hasMore ? (string)tokensEnum.Current : null; // the begin or end "'" has been found ! if ( "'".Equals(token) ) quoted = !quoted; ! ! if (quoted || char.IsWhiteSpace(token[0]) ) { ! result.Append(token); } ! else { ! bool isIdentifier = token[0]=='`' || ( // allow any identifier quoted with backtick ! Char.IsLetter(token[0]) && // only recognizes identifiers beginning with a letter ! !Keywords.Contains( token.ToLower() ) && ! token.IndexOf('.') < 0 ); ! if (afterFrom) { ! result.Append(token); afterFrom = false; afterFromTable = true; } ! else if (afterFromTable) { afterFromTable = false; ! result.Append(token); } ! else if ( isIdentifier && ( nextToken==null || !nextToken.Equals("(") )) // not a function call { ! result.Append(PlaceHolder) ! .Append(StringHelper.Dot) ! .Append( Quote(token, dialect) ); } ! else { ! if ( "from".Equals( token.ToLower() ) ) afterFrom = true; ! result.Append(token); } ! } } ! return result.ToString(); --- 105,163 ---- IEnumerator tokensEnum = tokens.GetEnumerator(); bool hasMore = tokensEnum.MoveNext(); ! string nextToken = hasMore ? ( string ) tokensEnum.Current : null; ! while( hasMore ) { string token = nextToken; hasMore = tokensEnum.MoveNext(); ! nextToken = hasMore ? ( string ) tokensEnum.Current : null; // the begin or end "'" has been found ! if( "'".Equals( token ) ) { ! quoted = !quoted; } ! ! if( quoted || char.IsWhiteSpace( token[ 0 ] ) ) { ! result.Append( token ); ! } ! else ! { ! bool isIdentifier = token[ 0 ] == '`' || ( // allow any identifier quoted with backtick ! Char.IsLetter( token[ 0 ] ) && // only recognizes identifiers beginning with a letter ! !Keywords.Contains( token.ToLower() ) && ! token.IndexOf( '.' ) < 0 ); ! if( afterFrom ) { ! result.Append( token ); afterFrom = false; afterFromTable = true; } ! else if( afterFromTable ) { afterFromTable = false; ! result.Append( token ); } ! else if( isIdentifier && ( nextToken == null || !nextToken.Equals( "(" ) ) ) // not a function call { ! result.Append( PlaceHolder ) ! .Append( StringHelper.Dot ) ! .Append( Quote( token, dialect ) ); } ! else { ! if( "from".Equals( token.ToLower() ) ) ! { ! afterFrom = true; ! } ! result.Append( token ); } ! } } ! return result.ToString(); *************** *** 166,187 **** /// <param name="dialect"></param> /// <returns></returns> ! public static string RenderOrderByStringTemplate(string sqlOrderByString, Dialect.Dialect dialect) { //TODO: make this a bit nicer ! StringTokenizer tokens = new StringTokenizer(sqlOrderByString, ",", false); ! StringBuilder result = new StringBuilder(sqlOrderByString.Length + 2); ! bool commaNeeded = false; IEnumerator tokenEnum = tokens.GetEnumerator(); ! while( tokenEnum.MoveNext() ) { ! string column = Quote(((string)tokenEnum.Current).Trim(), dialect); ! if (commaNeeded) result.Append(StringHelper.CommaSpace); commaNeeded = true; ! result.Append(PlaceHolder) ! .Append(StringHelper.Dot) ! .Append(column); } --- 170,194 ---- /// <param name="dialect"></param> /// <returns></returns> ! public static string RenderOrderByStringTemplate( string sqlOrderByString, Dialect.Dialect dialect ) { //TODO: make this a bit nicer ! StringTokenizer tokens = new StringTokenizer( sqlOrderByString, ",", false ); ! StringBuilder result = new StringBuilder( sqlOrderByString.Length + 2 ); ! bool commaNeeded = false; IEnumerator tokenEnum = tokens.GetEnumerator(); ! while( tokenEnum.MoveNext() ) { ! string column = Quote( ( ( string ) tokenEnum.Current ).Trim(), dialect ); ! if( commaNeeded ) ! { ! result.Append( StringHelper.CommaSpace ); ! } commaNeeded = true; ! result.Append( PlaceHolder ) ! .Append( StringHelper.Dot ) ! .Append( column ); } *************** *** 189,202 **** } ! private static string Quote(string column, Dialect.Dialect dialect) { ! ! if ( column[0] == '`' ) { ! if (column[column.Length -1] != '`') ! throw new ArgumentException("missing ` in column " + column); ! return dialect.QuoteForAliasName(column.Substring(1, column.Length - 2)); } ! else { return column; --- 196,210 ---- } ! private static string Quote( string column, Dialect.Dialect dialect ) { ! if( column[ 0 ] == '`' ) { ! if( column[ column.Length - 1 ] != '`' ) ! { ! throw new ArgumentException( "missing ` in column " + column ); ! } ! return dialect.QuoteForAliasName( column.Substring( 1, column.Length - 2 ) ); } ! else { return column; *************** *** 205,207 **** } ! } --- 213,215 ---- } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:25:54
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9327 Modified Files: SqlSelectBuilder.cs SqlSimpleSelectBuilder.cs SqlString.cs SqlStringBuilder.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: SqlSimpleSelectBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlSimpleSelectBuilder.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SqlSimpleSelectBuilder.cs 22 Nov 2004 03:56:08 -0000 1.2 --- SqlSimpleSelectBuilder.cs 31 Dec 2004 22:25:44 -0000 1.3 *************** *** 1,29 **** - using System; using System.Collections; - using System.Text; - - using NHibernate.Connection; - using NHibernate.Dialect; using NHibernate.Engine; - using NHibernate.Util; using NHibernate.Type; ! namespace NHibernate.SqlCommand { /// <summary> /// Summary description for SqlSimpleSelectBuilder. /// </summary> ! public class SqlSimpleSelectBuilder: SqlBaseBuilder, ISqlStringBuilder { ! ! ! string tableName; ! IList columnNames = new ArrayList(); // name of the column ! IList columnValues = new ArrayList(); //string or a Parameter ! IDictionary aliases = new Hashtable(); //key=column Name, value=column Alias ! int versionFragmentIndex = -1; ! int identityFragmentIndex = -1; ! IList whereStrings = new ArrayList(); //these can be plain strings because a forUpdate and orderBy will have --- 1,24 ---- using System.Collections; using NHibernate.Engine; using NHibernate.Type; + using NHibernate.Util; ! namespace NHibernate.SqlCommand ! { /// <summary> /// Summary description for SqlSimpleSelectBuilder. /// </summary> ! public class SqlSimpleSelectBuilder : SqlBaseBuilder, ISqlStringBuilder ! { ! private string tableName; ! private IList columnNames = new ArrayList(); // name of the column ! private IList columnValues = new ArrayList(); //string or a Parameter -- not used !?! ! private IDictionary aliases = new Hashtable(); //key=column Name, value=column Alias ! private int versionFragmentIndex = -1; // not used !?! ! private int identityFragmentIndex = -1; // not used !?! ! private IList whereStrings = new ArrayList(); //these can be plain strings because a forUpdate and orderBy will have *************** *** 33,41 **** private string orderBy; ! ! public SqlSimpleSelectBuilder(ISessionFactoryImplementor factory):base(factory) { } ! public SqlSimpleSelectBuilder SetTableName(string tableName) { this.tableName = tableName; return this; --- 28,46 ---- private string orderBy; ! /// <summary> ! /// ! /// </summary> ! /// <param name="factory"></param> ! public SqlSimpleSelectBuilder( ISessionFactoryImplementor factory ) : base( factory ) ! { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <returns></returns> ! public SqlSimpleSelectBuilder SetTableName( string tableName ) ! { this.tableName = tableName; return this; *************** *** 48,53 **** /// <param name="columnName">The name of the column to add.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumn(string columnName) { ! columnNames.Add(columnName); return this; } --- 53,59 ---- /// <param name="columnName">The name of the column to add.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumn( string columnName ) ! { ! columnNames.Add( columnName ); return this; } *************** *** 57,65 **** /// </summary> /// <param name="columnName">The name of the column to add.</param> ! /// <param name="aliase">The alias to use for the column</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumn(string columnName, string alias) { ! columnNames.Add(columnName); ! aliases[columnName] = alias; return this; } --- 63,72 ---- /// </summary> /// <param name="columnName">The name of the column to add.</param> ! /// <param name="alias">The alias to use for the column</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumn( string columnName, string alias ) ! { ! columnNames.Add( columnName ); ! aliases[ columnName ] = alias; return this; } *************** *** 70,76 **** /// <param name="columnNames">The names of the columns to add.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumns(string[] columnNames) { ! for (int i=0; i<columnNames.Length; i++) { ! AddColumn( columnNames[i]); } return this; --- 77,85 ---- /// <param name="columnNames">The names of the columns to add.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumns( string[ ] columnNames ) ! { ! for( int i = 0; i < columnNames.Length; i++ ) ! { ! AddColumn( columnNames[ i ] ); } return this; *************** *** 83,89 **** /// <param name="aliases">The aliases to use for the columns</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumns(string[] columnNames, string[] aliases) { ! for (int i=0; i<columnNames.Length; i++) { ! AddColumn( columnNames[i], aliases[i] ); } return this; --- 92,100 ---- /// <param name="aliases">The aliases to use for the columns</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddColumns( string[ ] columnNames, string[ ] aliases ) ! { ! for( int i = 0; i < columnNames.Length; i++ ) ! { ! AddColumn( columnNames[ i ], aliases[ i ] ); } return this; *************** *** 95,100 **** /// <param name="columnName">The name of the column to get the Alias for.</param> /// <returns>The Alias if one exists, null otherwise</returns> ! public string GetAlias(string columnName) { ! return (string) aliases[columnName]; } --- 106,112 ---- /// <param name="columnName">The name of the column to get the Alias for.</param> /// <returns>The Alias if one exists, null otherwise</returns> ! public string GetAlias( string columnName ) ! { ! return ( string ) aliases[ columnName ]; } *************** *** 105,113 **** /// <param name="identityType">The IType of the Identity Property.</param> /// <returns>The SqlSimpleSelectBuilder.</returns> ! public SqlSimpleSelectBuilder SetIdentityColumn(string[] columnNames, IType identityType) { ! Parameter[] parameters = Parameter.GenerateParameters( Factory, columnNames, identityType ); ! identityFragmentIndex = whereStrings.Add(ToWhereString(columnNames, parameters)); return this; --- 117,125 ---- /// <param name="identityType">The IType of the Identity Property.</param> /// <returns>The SqlSimpleSelectBuilder.</returns> ! public SqlSimpleSelectBuilder SetIdentityColumn( string[ ] columnNames, IType identityType ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, columnNames, identityType ); ! identityFragmentIndex = whereStrings.Add( ToWhereString( columnNames, parameters ) ); return this; *************** *** 120,128 **** /// <param name="versionType">The IVersionType of the Version Property.</param> /// <returns>The SqlSimpleSelectBuilder.</returns> ! public SqlSimpleSelectBuilder SetVersionColumn(string[] columnNames, IVersionType versionType) { ! Parameter[] parameters = Parameter.GenerateParameters( Factory, columnNames, versionType ); ! versionFragmentIndex = whereStrings.Add(ToWhereString(columnNames, parameters)); return this; --- 132,140 ---- /// <param name="versionType">The IVersionType of the Version Property.</param> /// <returns>The SqlSimpleSelectBuilder.</returns> ! public SqlSimpleSelectBuilder SetVersionColumn( string[ ] columnNames, IVersionType versionType ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, columnNames, versionType ); ! versionFragmentIndex = whereStrings.Add( ToWhereString( columnNames, parameters ) ); return this; *************** *** 134,138 **** /// <param name="fragment">The fragment to set.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder SetForUpdateFragment(string fragment){ this.forUpdateFragment = fragment; return this; --- 146,151 ---- /// <param name="fragment">The fragment to set.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder SetForUpdateFragment( string fragment ) ! { this.forUpdateFragment = fragment; return this; *************** *** 144,148 **** /// <param name="orderBy">The OrderBy fragment. It should include the SQL "ORDER BY"</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder SetOrderBy(string orderBy) { this.orderBy = orderBy; return this; --- 157,162 ---- /// <param name="orderBy">The OrderBy fragment. It should include the SQL "ORDER BY"</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder SetOrderBy( string orderBy ) ! { this.orderBy = orderBy; return this; *************** *** 156,172 **** /// <param name="op">The operator to put between the column name and value.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddWhereFragment(string[] columnNames, IType type, string op) { ! Parameter[] parameters = Parameter.GenerateParameters(Factory, columnNames, type); ! ! whereStrings.Add(ToWhereString(columnNames, parameters, op)); return this; } - #region ISqlStringBuilder Members ! public SqlString ToSqlString() { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); --- 170,187 ---- /// <param name="op">The operator to put between the column name and value.</param> /// <returns>The SqlSimpleSelectBuilder</returns> ! public SqlSimpleSelectBuilder AddWhereFragment( string[ ] columnNames, IType type, string op ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, columnNames, type ); ! ! whereStrings.Add( ToWhereString( columnNames, parameters, op ) ); return this; } #region ISqlStringBuilder Members ! /// <summary></summary> ! public SqlString ToSqlString() ! { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); *************** *** 174,190 **** bool commaNeeded = false; - - sqlBuilder.Add("SELECT "); ! for(int i = 0; i < columnNames.Count; i++) { ! string column = (string)columnNames[i]; ! string alias = GetAlias(column); ! ! if(commaNeeded) sqlBuilder.Add(StringHelper.CommaSpace); ! ! sqlBuilder.Add(column); ! if(alias!=null && !alias.Equals(column)) { ! sqlBuilder.Add(" AS ") ! .Add(alias); } --- 189,210 ---- bool commaNeeded = false; ! sqlBuilder.Add( "SELECT " ); ! ! for( int i = 0; i < columnNames.Count; i++ ) ! { ! string column = ( string ) columnNames[ i ]; ! string alias = GetAlias( column ); ! ! if( commaNeeded ) ! { ! sqlBuilder.Add( StringHelper.CommaSpace ); ! } ! ! sqlBuilder.Add( column ); ! if( alias != null && !alias.Equals( column ) ) ! { ! sqlBuilder.Add( " AS " ) ! .Add( alias ); } *************** *** 193,218 **** ! sqlBuilder.Add(" FROM ") ! .Add(tableName); ! sqlBuilder.Add(" WHERE "); ! if(whereStrings.Count > 1) { sqlBuilder.Add( ! (SqlString[])((ArrayList)whereStrings).ToArray(typeof(SqlString)), ! null, "AND", null, false); } ! else { ! sqlBuilder.Add((SqlString)whereStrings[0], null, null, null, false); } ! if (forUpdateFragment!=null) { ! sqlBuilder.Add(" ") ! .Add(forUpdateFragment) ! .Add(" "); } ! if (orderBy!=null) ! sqlBuilder.Add(orderBy); return sqlBuilder.ToSqlString(); --- 213,243 ---- ! sqlBuilder.Add( " FROM " ) ! .Add( tableName ); ! sqlBuilder.Add( " WHERE " ); ! if( whereStrings.Count > 1 ) ! { sqlBuilder.Add( ! ( SqlString[ ] ) ( ( ArrayList ) whereStrings ).ToArray( typeof( SqlString ) ), ! null, "AND", null, false ); } ! else ! { ! sqlBuilder.Add( ( SqlString ) whereStrings[ 0 ], null, null, null, false ); } ! if( forUpdateFragment != null ) ! { ! sqlBuilder.Add( " " ) ! .Add( forUpdateFragment ) ! .Add( " " ); } ! if( orderBy != null ) ! { ! sqlBuilder.Add( orderBy ); ! } return sqlBuilder.ToSqlString(); *************** *** 221,223 **** #endregion } ! } --- 246,248 ---- #endregion } ! } \ No newline at end of file Index: SqlString.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlString.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** SqlString.cs 22 Nov 2004 03:56:08 -0000 1.16 --- SqlString.cs 31 Dec 2004 22:25:44 -0000 1.17 *************** *** 3,9 **** using System.Text; ! namespace NHibernate.SqlCommand { - /// <summary> /// This is a non-modifiable Sql statement that is ready to be prepared --- 3,8 ---- using System.Text; ! namespace NHibernate.SqlCommand { /// <summary> /// This is a non-modifiable Sql statement that is ready to be prepared *************** *** 14,34 **** /// </summary> [Serializable] ! public class SqlString : ICloneable { ! readonly object[] sqlParts; ! private int[] parameterIndexes; ! public SqlString(string sqlPart) : this(new object[] {sqlPart}) { } ! public SqlString(object[] sqlParts) { this.sqlParts = sqlParts; } ! public object[] SqlParts { ! get { return sqlParts;} } --- 13,42 ---- /// </summary> [Serializable] ! public class SqlString : ICloneable { ! private readonly object[ ] sqlParts; ! private int[ ] parameterIndexes; ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlPart"></param> ! public SqlString( string sqlPart ) : this( new object[ ] {sqlPart} ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlParts"></param> ! public SqlString( object[ ] sqlParts ) { this.sqlParts = sqlParts; } ! /// <summary></summary> ! public object[ ] SqlParts { ! get { return sqlParts; } } *************** *** 43,53 **** /// are called it is better to use the SqlStringBuilder. /// </remarks> ! public SqlString Append(SqlString rhs) { ! object[] temp = new object[rhs.SqlParts.Length + sqlParts.Length]; ! Array.Copy(sqlParts, 0, temp, 0, sqlParts.Length); ! Array.Copy(rhs.SqlParts, 0, temp, sqlParts.Length, rhs.SqlParts.Length); ! return new SqlString(temp); } --- 51,61 ---- /// are called it is better to use the SqlStringBuilder. /// </remarks> ! public SqlString Append( SqlString rhs ) { ! object[ ] temp = new object[rhs.SqlParts.Length + sqlParts.Length]; ! Array.Copy( sqlParts, 0, temp, 0, sqlParts.Length ); ! Array.Copy( rhs.SqlParts, 0, temp, sqlParts.Length, rhs.SqlParts.Length ); ! return new SqlString( temp ); } *************** *** 62,72 **** /// are called it is better to use the SqlStringBuilder. /// </remarks> ! public SqlString Append(string rhs) { ! object[] temp = new object[ sqlParts.Length + 1]; ! Array.Copy(sqlParts, 0, temp, 0, sqlParts.Length); ! temp[sqlParts.Length] = rhs; ! ! return new SqlString(temp); } --- 70,80 ---- /// are called it is better to use the SqlStringBuilder. /// </remarks> ! public SqlString Append( string rhs ) { ! object[ ] temp = new object[sqlParts.Length + 1]; ! Array.Copy( sqlParts, 0, temp, 0, sqlParts.Length ); ! temp[ sqlParts.Length ] = rhs; ! ! return new SqlString( temp ); } *************** *** 79,83 **** /// one SqlPart. /// </remarks> ! public SqlString Compact() { StringBuilder builder = new StringBuilder(); --- 87,91 ---- /// one SqlPart. /// </remarks> ! public SqlString Compact() { StringBuilder builder = new StringBuilder(); *************** *** 85,102 **** string builderString = String.Empty; ! foreach(object part in SqlParts) { string stringPart = part as string; ! if(stringPart!=null) { ! builder.Append(stringPart); } ! else { builderString = builder.ToString(); ! // don't add an empty string into the new compacted SqlString ! if( builderString.Length!=0 ) { sqlBuilder.Add( builderString ); --- 93,110 ---- string builderString = String.Empty; ! foreach( object part in SqlParts ) { string stringPart = part as string; ! if( stringPart != null ) { ! builder.Append( stringPart ); } ! else { builderString = builder.ToString(); ! // don't add an empty string into the new compacted SqlString ! if( builderString.Length != 0 ) { sqlBuilder.Add( builderString ); *************** *** 104,109 **** builder = new StringBuilder(); ! ! sqlBuilder.Add((Parameter)part); } --- 112,117 ---- builder = new StringBuilder(); ! ! sqlBuilder.Add( ( Parameter ) part ); } *************** *** 113,119 **** builderString = builder.ToString(); ! if(builderString.Length > 0) { ! sqlBuilder.Add(builderString); } --- 121,127 ---- builderString = builder.ToString(); ! if( builderString.Length > 0 ) { ! sqlBuilder.Add( builderString ); } *************** *** 125,138 **** /// </summary> /// <value>true if there is a Parameter with a null SqlType.</value> ! public bool ContainsUntypedParameter { ! get { ! for(int i=0; i<sqlParts.Length; i++) { ! Parameter paramPart = sqlParts[i] as Parameter; ! if(paramPart!=null) { ! if( paramPart.SqlType==null ) { // only need to find one null SqlType --- 133,146 ---- /// </summary> /// <value>true if there is a Parameter with a null SqlType.</value> ! public bool ContainsUntypedParameter { ! get { ! for( int i = 0; i < sqlParts.Length; i++ ) { ! Parameter paramPart = sqlParts[ i ] as Parameter; ! if( paramPart != null ) { ! if( paramPart.SqlType == null ) { // only need to find one null SqlType *************** *** 154,170 **** /// for the Count. /// </remarks> ! public int Count { ! get { int count = 0; ! for( int i=0; i<sqlParts.Length; i++ ) { ! SqlString sqlString = sqlParts[i] as SqlString; ! if( sqlString!=null ) { count += sqlString.Count; } ! else { count++; --- 162,178 ---- /// for the Count. /// </remarks> ! public int Count { ! get { int count = 0; ! for( int i = 0; i < sqlParts.Length; i++ ) { ! SqlString sqlString = sqlParts[ i ] as SqlString; ! if( sqlString != null ) { count += sqlString.Count; } ! else { count++; *************** *** 181,185 **** /// <param name="value">A string to seek at the end.</param> /// <returns><c>true</c> if the end of this instance matches value; otherwise, <c>false</c></returns> ! public bool EndsWith(string value) { SqlString tempSql = Compact(); --- 189,193 ---- /// <param name="value">A string to seek at the end.</param> /// <returns><c>true</c> if the end of this instance matches value; otherwise, <c>false</c></returns> ! public bool EndsWith( string value ) { SqlString tempSql = Compact(); *************** *** 187,191 **** int endIndex = tempSql.SqlParts.Length - 1; ! if( tempSql.SqlParts.Length==0 ) { return false; --- 195,199 ---- int endIndex = tempSql.SqlParts.Length - 1; ! if( tempSql.SqlParts.Length == 0 ) { return false; *************** *** 193,200 **** ! string lastPart = tempSql.SqlParts[endIndex] as string; ! if(lastPart!=null) { ! return lastPart.EndsWith(value); } --- 201,208 ---- ! string lastPart = tempSql.SqlParts[ endIndex ] as string; ! if( lastPart != null ) { ! return lastPart.EndsWith( value ); } *************** *** 208,231 **** /// An Int32 array that contains the indexes of the Parameters in the SqlPart array. /// </value> ! public int[] ParameterIndexes { get { // only calculate this one time because this object is immutable. ! if( parameterIndexes==null ) { ArrayList paramList = new ArrayList(); ! for(int i=0; i<sqlParts.Length; i++) { ! if(sqlParts[i] is Parameter) { ! paramList.Add(i); } } ! parameterIndexes = (int[])paramList.ToArray( typeof(int) ); } ! return parameterIndexes ; } --- 216,239 ---- /// An Int32 array that contains the indexes of the Parameters in the SqlPart array. /// </value> ! public int[ ] ParameterIndexes { get { // only calculate this one time because this object is immutable. ! if( parameterIndexes == null ) { ArrayList paramList = new ArrayList(); ! for( int i = 0; i < sqlParts.Length; i++ ) { ! if( sqlParts[ i ] is Parameter ) { ! paramList.Add( i ); } } ! parameterIndexes = ( int[ ] ) paramList.ToArray( typeof( int ) ); } ! return parameterIndexes; } *************** *** 242,246 **** /// in the Compacted form. /// </returns> ! public SqlString Replace(string oldValue, string newValue) { // compacting returns a new SqlString object, so we are free to modify --- 250,254 ---- /// in the Compacted form. /// </returns> ! public SqlString Replace( string oldValue, string newValue ) { // compacting returns a new SqlString object, so we are free to modify *************** *** 250,259 **** SqlString compacted = this.Compact(); ! for( int i=0; i<compacted.SqlParts.Length; i++ ) { ! string sqlPart = compacted.SqlParts[i] as string; ! if( sqlPart!=null ) { ! compacted.SqlParts[i] = sqlPart.Replace( oldValue, newValue ); } } --- 258,267 ---- SqlString compacted = this.Compact(); ! for( int i = 0; i < compacted.SqlParts.Length; i++ ) { ! string sqlPart = compacted.SqlParts[ i ] as string; ! if( sqlPart != null ) { ! compacted.SqlParts[ i ] = sqlPart.Replace( oldValue, newValue ); } } *************** *** 267,282 **** /// <param name="value">The System.String to seek</param> /// <returns>true if the SqlString starts with the value.</returns> ! public bool StartsWith(string value) { - SqlString tempSql = this.Compact(); ! foreach(object sqlPart in tempSql.SqlParts) { string partText = sqlPart as string; ! // if this part is not a string then we know we did not start with the string // value ! if(partText==null) { return false; --- 275,289 ---- /// <param name="value">The System.String to seek</param> /// <returns>true if the SqlString starts with the value.</returns> ! public bool StartsWith( string value ) { SqlString tempSql = this.Compact(); ! foreach( object sqlPart in tempSql.SqlParts ) { string partText = sqlPart as string; ! // if this part is not a string then we know we did not start with the string // value ! if( partText == null ) { return false; *************** *** 286,292 **** // move on to the next SqlPart, otherwise lets make sure that // it does in fact start with the value ! if(partText.Length > 0) { ! return partText.StartsWith(value); } } --- 293,299 ---- // move on to the next SqlPart, otherwise lets make sure that // it does in fact start with the value ! if( partText.Length > 0 ) { ! return partText.StartsWith( value ); } } *************** *** 312,332 **** /// will be the Parameter. /// </remarks> ! public SqlString Substring(int startIndex) { SqlStringBuilder builder = new SqlStringBuilder( Compact() ); ! string part = builder[0] as string; // if the first part is null then it is not a string so just // return them the compacted version ! if( part!=null ) { ! if(part.Length < startIndex) { ! builder.RemoveAt(0); } ! else { ! builder[0] = part.Substring(startIndex); } } --- 319,339 ---- /// will be the Parameter. /// </remarks> ! public SqlString Substring( int startIndex ) { SqlStringBuilder builder = new SqlStringBuilder( Compact() ); ! string part = builder[ 0 ] as string; // if the first part is null then it is not a string so just // return them the compacted version ! if( part != null ) { ! if( part.Length < startIndex ) { ! builder.RemoveAt( 0 ); } ! else { ! builder[ 0 ] = part.Substring( startIndex ); } } *************** *** 342,373 **** /// are removed from the beginning and end. /// </returns> ! public SqlString Trim() { SqlStringBuilder builder = new SqlStringBuilder( Compact() ); // there is nothing in the builder to Trim ! if( builder.Count==0 ) { return builder.ToSqlString(); } ! string begin = builder[0] as string; int endIndex = builder.Count - 1; ! string end = builder[endIndex] as string; ! if( endIndex==0 && begin!=null ) { ! builder[0] = begin.Trim(); } ! else { ! if(begin!=null) { ! builder[0] = begin.TrimStart(); } ! if(end!=null) { ! builder[builder.Count - 1] = end.TrimEnd(); } } --- 349,380 ---- /// are removed from the beginning and end. /// </returns> ! public SqlString Trim() { SqlStringBuilder builder = new SqlStringBuilder( Compact() ); // there is nothing in the builder to Trim ! if( builder.Count == 0 ) { return builder.ToSqlString(); } ! string begin = builder[ 0 ] as string; int endIndex = builder.Count - 1; ! string end = builder[ endIndex ] as string; ! if( endIndex == 0 && begin != null ) { ! builder[ 0 ] = begin.Trim(); } ! else { ! if( begin != null ) { ! builder[ 0 ] = begin.TrimStart(); } ! if( end != null ) { ! builder[ builder.Count - 1 ] = end.TrimEnd(); } } *************** *** 377,397 **** #region System.Object Members ! ! ! public override bool Equals(object obj) { SqlString rhs; ! // Step1: Perform an equals test ! if(obj==this) return true; // Step 2: Instance of check rhs = obj as SqlString; ! if(rhs==null) return false; //Step 3: Check each important field ! for(int i = 0; i < sqlParts.Length; i++) { ! if( this.sqlParts[i].Equals(rhs.SqlParts[i]) == false ) return false; } --- 384,417 ---- #region System.Object Members ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="obj"></param> ! /// <returns></returns> ! public override bool Equals( object obj ) { SqlString rhs; ! // Step1: Perform an equals test ! if( obj == this ) ! { ! return true; ! } // Step 2: Instance of check rhs = obj as SqlString; ! if( rhs == null ) ! { ! return false; ! } //Step 3: Check each important field ! for( int i = 0; i < sqlParts.Length; i++ ) { ! if( this.sqlParts[ i ].Equals( rhs.SqlParts[ i ] ) == false ) ! { ! return false; ! } } *************** *** 399,411 **** } public override int GetHashCode() { int hashCode = 0; ! unchecked { ! for(int i = 0; i < sqlParts.Length; i++) { ! hashCode += sqlParts[i].GetHashCode(); } } --- 419,432 ---- } + /// <summary></summary> public override int GetHashCode() { int hashCode = 0; ! unchecked { ! for( int i = 0; i < sqlParts.Length; i++ ) { ! hashCode += sqlParts[ i ].GetHashCode(); } } *************** *** 423,464 **** /// </summary> /// <returns>A Provider nuetral version of the CommandText</returns> ! public override string ToString() { ! StringBuilder builder = new StringBuilder(sqlParts.Length * 15); ! for(int i = 0; i < sqlParts.Length; i++) { ! builder.Append(sqlParts[i].ToString()); } return builder.ToString(); } ! #endregion ! #region ICloneable Members ! public SqlString Clone() { ! object[] clonedParts = new object[sqlParts.Length]; Parameter param; ! for(int i = 0; i < sqlParts.Length; i++) ! { ! param = sqlParts[i] as Parameter; ! if(param!=null) { ! clonedParts[i] = param.Clone(); } ! else { ! clonedParts[i] = (string)sqlParts[i]; } } ! return new SqlString(clonedParts); } ! object ICloneable.Clone() { return Clone(); --- 444,487 ---- /// </summary> /// <returns>A Provider nuetral version of the CommandText</returns> ! public override string ToString() { ! StringBuilder builder = new StringBuilder( sqlParts.Length*15 ); ! for( int i = 0; i < sqlParts.Length; i++ ) { ! builder.Append( sqlParts[ i ].ToString() ); } return builder.ToString(); } ! #endregion ! #region ICloneable Members ! /// <summary></summary> ! public SqlString Clone() { ! object[ ] clonedParts = new object[sqlParts.Length]; Parameter param; ! for( int i = 0; i < sqlParts.Length; i++ ) ! { ! param = sqlParts[ i ] as Parameter; ! if( param != null ) { ! clonedParts[ i ] = param.Clone(); } ! else { ! clonedParts[ i ] = ( string ) sqlParts[ i ]; } } ! return new SqlString( clonedParts ); } ! /// <summary></summary> ! object ICloneable.Clone() { return Clone(); *************** *** 467,469 **** #endregion } ! } --- 490,492 ---- #endregion } ! } \ No newline at end of file Index: SqlStringBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlStringBuilder.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SqlStringBuilder.cs 13 Sep 2004 07:22:38 -0000 1.5 --- SqlStringBuilder.cs 31 Dec 2004 22:25:44 -0000 1.6 *************** *** 2,6 **** using System.Collections; ! namespace NHibernate.SqlCommand { /// <summary> --- 2,6 ---- using System.Collections; ! namespace NHibernate.SqlCommand { /// <summary> *************** *** 27,40 **** /// to make sure the correct sql is getting built are specific to MsSql2000Dialect. /// </remarks> ! public class SqlStringBuilder : ISqlStringBuilder { - // this holds the strings and parameters that make up the full sql statement. ! ArrayList sqlParts; ! /// <summary> /// Create an empty StringBuilder with the default capacity. /// </summary> ! public SqlStringBuilder() : this(16) { } --- 27,39 ---- /// to make sure the correct sql is getting built are specific to MsSql2000Dialect. /// </remarks> ! public class SqlStringBuilder : ISqlStringBuilder { // this holds the strings and parameters that make up the full sql statement. ! private ArrayList sqlParts; ! /// <summary> /// Create an empty StringBuilder with the default capacity. /// </summary> ! public SqlStringBuilder() : this( 16 ) { } *************** *** 44,50 **** /// </summary> /// <param name="partsCapacity">The number of parts expected.</param> ! public SqlStringBuilder(int partsCapacity) { ! sqlParts = new ArrayList(partsCapacity); } --- 43,49 ---- /// </summary> /// <param name="partsCapacity">The number of parts expected.</param> ! public SqlStringBuilder( int partsCapacity ) { ! sqlParts = new ArrayList( partsCapacity ); } *************** *** 53,62 **** /// </summary> /// <param name="sqlString">The SqlString to modify.</param> ! public SqlStringBuilder(SqlString sqlString) { ! sqlParts = new ArrayList(sqlString.SqlParts.Length); ! foreach(object part in sqlString.SqlParts) { ! sqlParts.Add(part); } } --- 52,61 ---- /// </summary> /// <param name="sqlString">The SqlString to modify.</param> ! public SqlStringBuilder( SqlString sqlString ) { ! sqlParts = new ArrayList( sqlString.SqlParts.Length ); ! foreach( object part in sqlString.SqlParts ) { ! sqlParts.Add( part ); } } *************** *** 67,73 **** /// <param name="sql">The string to add.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add(string sql) { ! sqlParts.Add(sql); return this; } --- 66,72 ---- /// <param name="sql">The string to add.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add( string sql ) { ! sqlParts.Add( sql ); return this; } *************** *** 81,87 **** /// <param name="parameter">The Parameter to add.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add(Parameter parameter) { ! sqlParts.Add(parameter); return this; } --- 80,86 ---- /// <param name="parameter">The Parameter to add.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add( Parameter parameter ) { ! sqlParts.Add( parameter ); return this; } *************** *** 94,114 **** /// <returns>This SqlStringBuilder.</returns> /// <exception cref="ArgumentException">Thrown when the part is not a Parameter, String, or SqlString.</exception> ! public SqlStringBuilder AddObject(object part) { ! if(part is Parameter) { ! return this.Add((Parameter)part); } ! else if (part is String) { ! return this.Add((String)part); } ! else if (part is SqlString) { ! return this.Add((SqlString)part, null, null, null); } ! else { ! throw new ArgumentException("Part was not a Parameter, String, or SqlString."); } } --- 93,113 ---- /// <returns>This SqlStringBuilder.</returns> /// <exception cref="ArgumentException">Thrown when the part is not a Parameter, String, or SqlString.</exception> ! public SqlStringBuilder AddObject( object part ) { ! if( part is Parameter ) { ! return this.Add( ( Parameter ) part ); } ! else if( part is String ) { ! return this.Add( ( String ) part ); } ! else if( part is SqlString ) { ! return this.Add( ( SqlString ) part, null, null, null ); } ! else { ! throw new ArgumentException( "Part was not a Parameter, String, or SqlString." ); } } *************** *** 122,133 **** /// <returns>This SqlStringBuilder</returns> /// <remarks>This calls the overloaded Add(sqlString, null, null, null, false)</remarks> ! public SqlStringBuilder Add(SqlString sqlString) { ! return Add(sqlString, null, null, null, false); } - - /// <summary> /// Adds an existing SqlString to this SqlStringBuilder --- 121,130 ---- /// <returns>This SqlStringBuilder</returns> /// <remarks>This calls the overloaded Add(sqlString, null, null, null, false)</remarks> ! public SqlStringBuilder Add( SqlString sqlString ) { ! return Add( sqlString, null, null, null, false ); } /// <summary> /// Adds an existing SqlString to this SqlStringBuilder *************** *** 142,148 **** /// so it will not be wrapped with a "(" and ")" /// </remarks> ! public SqlStringBuilder Add(SqlString sqlString, string prefix, string op, string postfix) { ! return Add(new SqlString[] {sqlString}, prefix, op, postfix, false); } --- 139,145 ---- /// so it will not be wrapped with a "(" and ")" /// </remarks> ! public SqlStringBuilder Add( SqlString sqlString, string prefix, string op, string postfix ) { ! return Add( new SqlString[ ] {sqlString}, prefix, op, postfix, false ); } *************** *** 156,162 **** /// <param name="wrapStatement">Wrap each SqlStrings with "(" and ")"</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add(SqlString sqlString, string prefix, string op, string postfix, bool wrapStatement) { ! return Add(new SqlString[] {sqlString}, prefix, op, postfix, wrapStatement); } --- 153,159 ---- /// <param name="wrapStatement">Wrap each SqlStrings with "(" and ")"</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add( SqlString sqlString, string prefix, string op, string postfix, bool wrapStatement ) { ! return Add( new SqlString[ ] {sqlString}, prefix, op, postfix, wrapStatement ); } *************** *** 170,176 **** /// <returns>This SqlStringBuilder</returns> /// <remarks>This calls the overloaded Add method with wrapStatement=true</remarks> ! public SqlStringBuilder Add(SqlString[] sqlStrings, string prefix, string op, string postfix) { ! return Add(sqlStrings, prefix, op, postfix, true); } --- 167,173 ---- /// <returns>This SqlStringBuilder</returns> /// <remarks>This calls the overloaded Add method with wrapStatement=true</remarks> ! public SqlStringBuilder Add( SqlString[ ] sqlStrings, string prefix, string op, string postfix ) { ! return Add( sqlStrings, prefix, op, postfix, true ); } *************** *** 178,182 **** /// Adds existing SqlStrings to this SqlStringBuilder /// </summary> ! /// <param name="statements">The SqlStrings to combine.</param> /// <param name="prefix">String to put at the beginning of the combined SqlStrings.</param> /// <param name="op">How these SqlStrings should be junctioned "AND" or "OR"</param> --- 175,179 ---- /// Adds existing SqlStrings to this SqlStringBuilder /// </summary> ! /// <param name="sqlStrings">The SqlStrings to combine.</param> /// <param name="prefix">String to put at the beginning of the combined SqlStrings.</param> /// <param name="op">How these SqlStrings should be junctioned "AND" or "OR"</param> *************** *** 184,214 **** /// <param name="wrapStatement">Wrap each SqlStrings with "(" and ")"</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add(SqlString[] sqlStrings, string prefix, string op, string postfix, bool wrapStatement) { ! ! if( prefix!=null ) sqlParts.Add(prefix); ! bool opNeeded = false; ! ! foreach(SqlString sqlString in sqlStrings) { ! if(opNeeded) sqlParts.Add(" " + op + " "); ! ! opNeeded=true; ! if(wrapStatement) sqlParts.Add("("); ! ! foreach(object sqlPart in sqlString.SqlParts) { ! sqlParts.Add(sqlPart); } ! if(wrapStatement) sqlParts.Add(")"); ! ! } - if( postfix!=null ) sqlParts.Add(postfix); - return this; } --- 181,225 ---- /// <param name="wrapStatement">Wrap each SqlStrings with "(" and ")"</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Add( SqlString[ ] sqlStrings, string prefix, string op, string postfix, bool wrapStatement ) { ! if( prefix != null ) ! { ! sqlParts.Add( prefix ); ! } ! bool opNeeded = false; ! ! foreach( SqlString sqlString in sqlStrings ) { ! if( opNeeded ) ! { ! sqlParts.Add( " " + op + " " ); ! } ! opNeeded = true; ! ! if( wrapStatement ) { ! sqlParts.Add( "(" ); } ! foreach( object sqlPart in sqlString.SqlParts ) ! { ! sqlParts.Add( sqlPart ); ! } ! ! if( wrapStatement ) ! { ! sqlParts.Add( ")" ); ! } ! ! ! } ! ! if( postfix != null ) ! { ! sqlParts.Add( postfix ); } return this; } *************** *** 230,243 **** /// <value>Returns a string or Parameter.</value> /// <remarks></remarks> ! public object this[int index] { ! get ! { ! return sqlParts[index]; ! } ! set ! { ! sqlParts[index] = value; ! } } --- 241,248 ---- /// <value>Returns a string or Parameter.</value> /// <remarks></remarks> ! public object this[ int index ] { ! get { return sqlParts[ index ]; } ! set { sqlParts[ index ] = value; } } *************** *** 248,254 **** /// <param name="sql">The string containing sql to insert.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Insert(int index, string sql) { ! sqlParts.Insert(index, sql); return this; } --- 253,259 ---- /// <param name="sql">The string containing sql to insert.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Insert( int index, string sql ) { ! sqlParts.Insert( index, sql ); return this; } *************** *** 260,266 **** /// <param name="param">The Parameter to insert.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Insert(int index, Parameter param) { ! sqlParts.Insert(index, param); return this; } --- 265,271 ---- /// <param name="param">The Parameter to insert.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder Insert( int index, Parameter param ) { ! sqlParts.Insert( index, param ); return this; } *************** *** 271,277 **** /// <param name="index">The zero-based index of the item to remove.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder RemoveAt(int index) { ! sqlParts.RemoveAt(index); return this; } --- 276,282 ---- /// <param name="index">The zero-based index of the item to remove.</param> /// <returns>This SqlStringBuilder</returns> ! public SqlStringBuilder RemoveAt( int index ) { ! sqlParts.RemoveAt( index ); return this; } *************** *** 281,288 **** /// </summary> /// <returns>The SqlString that was built.</returns> ! public SqlString ToSqlString() { ! return new SqlString((object[])sqlParts.ToArray(typeof(object))); } } ! } --- 286,293 ---- /// </summary> /// <returns>The SqlString that was built.</returns> ! public SqlString ToSqlString() { ! return new SqlString( ( object[ ] ) sqlParts.ToArray( typeof( object ) ) ); } } ! } \ No newline at end of file Index: SqlSelectBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SqlSelectBuilder.cs 4 Dec 2004 22:24:16 -0000 1.6 --- SqlSelectBuilder.cs 31 Dec 2004 22:25:44 -0000 1.7 *************** *** 1,20 **** using System; using System.Collections; ! using System.Data; ! using System.Text; ! ! using NHibernate.Connection; using NHibernate.Engine; using NHibernate.Type; - using NHibernate.Util; ! namespace NHibernate.SqlCommand { /// <summary> /// A class that builds an <c>INSERT</c> sql statement. /// </summary> ! public class SqlSelectBuilder: SqlBaseBuilder, ISqlStringBuilder { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(SqlSelectBuilder) ); private string selectClause; --- 1,16 ---- using System; using System.Collections; ! using log4net; using NHibernate.Engine; using NHibernate.Type; ! namespace NHibernate.SqlCommand { /// <summary> /// A class that builds an <c>INSERT</c> sql statement. /// </summary> ! public class SqlSelectBuilder : SqlBaseBuilder, ISqlStringBuilder { ! private static readonly ILog log = LogManager.GetLogger( typeof( SqlSelectBuilder ) ); private string selectClause; *************** *** 24,30 **** private string orderByClause; ! IList whereSqlStrings = new ArrayList(); ! public SqlSelectBuilder(ISessionFactoryImplementor factory): base(factory) { } --- 20,30 ---- private string orderByClause; ! private IList whereSqlStrings = new ArrayList(); ! /// <summary> ! /// ! /// </summary> ! /// <param name="factory"></param> ! public SqlSelectBuilder( ISessionFactoryImplementor factory ) : base( factory ) { } *************** *** 35,39 **** /// <param name="fromClause">The fromClause to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetFromClause(string fromClause) { this.fromClause = fromClause; --- 35,39 ---- /// <param name="fromClause">The fromClause to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetFromClause( string fromClause ) { this.fromClause = fromClause; *************** *** 47,51 **** /// <param name="alias">The Alias to use for the table name.</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetFromClause(string tableName, string alias) { this.fromClause = tableName + " " + alias; --- 47,51 ---- /// <param name="alias">The Alias to use for the table name.</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetFromClause( string tableName, string alias ) { this.fromClause = tableName + " " + alias; *************** *** 58,62 **** /// <param name="fromClause">The fromClause in a SqlString</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetFromClause(SqlString fromClause) { // it is safe to do this because a fromClause will have no --- 58,62 ---- /// <param name="fromClause">The fromClause in a SqlString</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetFromClause( SqlString fromClause ) { // it is safe to do this because a fromClause will have no *************** *** 70,74 **** /// <param name="orderByClause">The orderByClause to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetOrderByClause(string orderByClause) { this.orderByClause = orderByClause; --- 70,74 ---- /// <param name="orderByClause">The orderByClause to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetOrderByClause( string orderByClause ) { this.orderByClause = orderByClause; *************** *** 88,109 **** /// <param name="outerJoinsAfterWhere">The outerJoinsAfterWhere to set</param> /// <returns>The SqlSelectBuilder</returns> ! [Obsolete("Should use SqlString version instead")] ! public SqlSelectBuilder SetOuterJoins(string outerJoinsAfterFrom, string outerJoinsAfterWhere) { ! return this.SetOuterJoins( new SqlString(outerJoinsAfterFrom), new SqlString(outerJoinsAfterWhere) ); } ! [Obsolete("Should use SqlString version instead")] ! public SqlSelectBuilder SetOuterJoins(SqlString outerJoinsAfterFrom, string outerJoinsAfterWhere) { ! return this.SetOuterJoins( outerJoinsAfterFrom, new SqlString(outerJoinsAfterWhere) ); } ! [Obsolete("Should use SqlString version instead")] ! public SqlSelectBuilder SetOuterJoins(string outerJoinsAfterFrom, SqlString outerJoinsAfterWhere) { ! return this.SetOuterJoins( new SqlString(outerJoinsAfterFrom), outerJoinsAfterWhere ); } ! /// <summary> /// Sets the SqlString for the OUTER JOINs. --- 88,121 ---- /// <param name="outerJoinsAfterWhere">The outerJoinsAfterWhere to set</param> /// <returns>The SqlSelectBuilder</returns> ! [Obsolete( "Should use SqlString version instead" )] ! public SqlSelectBuilder SetOuterJoins( string outerJoinsAfterFrom, string outerJoinsAfterWhere ) { ! return this.SetOuterJoins( new SqlString( outerJoinsAfterFrom ), new SqlString( outerJoinsAfterWhere ) ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="outerJoinsAfterFrom"></param> ! /// <param name="outerJoinsAfterWhere"></param> ! /// <returns></returns> ! [Obsolete( "Should use SqlString version instead" )] ! public SqlSelectBuilder SetOuterJoins( SqlString outerJoinsAfterFrom, string outerJoinsAfterWhere ) { ! return this.SetOuterJoins( outerJoinsAfterFrom, new SqlString( outerJoinsAfterWhere ) ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="outerJoinsAfterFrom"></param> ! /// <param name="outerJoinsAfterWhere"></param> ! /// <returns></returns> ! [Obsolete( "Should use SqlString version instead" )] ! public SqlSelectBuilder SetOuterJoins( string outerJoinsAfterFrom, SqlString outerJoinsAfterWhere ) { ! return this.SetOuterJoins( new SqlString( outerJoinsAfterFrom ), outerJoinsAfterWhere ); } ! /// <summary> /// Sets the SqlString for the OUTER JOINs. *************** *** 116,120 **** /// <param name="outerJoinsAfterWhere">The outerJoinsAfterWhere to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetOuterJoins(SqlString outerJoinsAfterFrom, SqlString outerJoinsAfterWhere) { this.outerJoinsAfterFrom = outerJoinsAfterFrom; --- 128,132 ---- /// <param name="outerJoinsAfterWhere">The outerJoinsAfterWhere to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetOuterJoins( SqlString outerJoinsAfterFrom, SqlString outerJoinsAfterWhere ) { this.outerJoinsAfterFrom = outerJoinsAfterFrom; *************** *** 128,132 **** /// <param name="selectClause">The selectClause to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetSelectClause(string selectClause) { this.selectClause = selectClause; --- 140,144 ---- /// <param name="selectClause">The selectClause to set</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetSelectClause( string selectClause ) { this.selectClause = selectClause; *************** *** 141,149 **** /// <param name="whereType">The Hibernate Type</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetWhereClause(string tableAlias, string[] columnNames, IType whereType) { ! Parameter[] parameters = Parameter.GenerateParameters( Factory, tableAlias, columnNames, whereType ); ! whereSqlStrings.Add(ToWhereString(tableAlias, columnNames, parameters)); return this; --- 153,161 ---- /// <param name="whereType">The Hibernate Type</param> /// <returns>The SqlSelectBuilder</returns> ! public SqlSelectBuilder SetWhereClause( string tableAlias, string[ ] columnNames, IType whereType ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, tableAlias, columnNames, whereType ); ! whereSqlStrings.Add( ToWhereString( tableAlias, columnNames, parameters ) ); return this; *************** *** 156,168 **** /// <param name="whereSqlString">The SqlString that contains the sql and parameters to add to the WHERE</param> /// <returns>This SqlSelectBuilder</returns> ! public SqlSelectBuilder AddWhereClause(SqlString whereSqlString) { ! whereSqlStrings.Add(whereSqlString); return this; } - #region ISqlStringBuilder Members public SqlString ToSqlString() { --- 168,180 ---- /// <param name="whereSqlString">The SqlString that contains the sql and parameters to add to the WHERE</param> /// <returns>This SqlSelectBuilder</returns> ! public SqlSelectBuilder AddWhereClause( SqlString whereSqlString ) { ! whereSqlStrings.Add( whereSqlString ); return this; } #region ISqlStringBuilder Members + /// <summary></summary> public SqlString ToSqlString() { *************** *** 175,225 **** // move through each whereSqlString to find the capacity ! for( int i=0; i<whereSqlStrings.Count; i++ ) { ! initialCapacity += ((SqlString)whereSqlStrings[i]).Count; } ! SqlStringBuilder sqlBuilder = new SqlStringBuilder( initialCapacity + 2 ); ! sqlBuilder.Add("SELECT ") ! .Add(selectClause) ! .Add(" FROM ") ! .Add(fromClause) ! .Add(outerJoinsAfterFrom); ! sqlBuilder.Add(" WHERE "); ! if(whereSqlStrings.Count > 1) { sqlBuilder.Add( ! (SqlString[])((ArrayList)whereSqlStrings).ToArray(typeof(SqlString)), ! null, "AND", null, false); } ! else { ! sqlBuilder.Add( (SqlString)whereSqlStrings[0], null, null, null, false ); } ! sqlBuilder.Add(outerJoinsAfterWhere); ! ! if (orderByClause != null && orderByClause.Trim().Length > 0) { ! sqlBuilder.Add(" ORDER BY ") ! .Add(orderByClause); } ! if(log.IsDebugEnabled) { ! if( initialCapacity < sqlBuilder.Count ) { ! log.Debug( "The initial capacity was set too low at: " + initialCapacity + " for the SelectSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + fromClause ); } ! else if( initialCapacity > 16 && ((float)initialCapacity/sqlBuilder.Count) > 1.2 ) { log.Debug( "The initial capacity was set too high at: " + initialCapacity + " for the SelectSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + fromClause ); } } --- 187,237 ---- // move through each whereSqlString to find the capacity ! for( int i = 0; i < whereSqlStrings.Count; i++ ) { ! initialCapacity += ( ( SqlString ) whereSqlStrings[ i ] ).Count; } ! SqlStringBuilder sqlBuilder = new SqlStringBuilder( initialCapacity + 2 ); ! sqlBuilder.Add( "SELECT " ) ! .Add( selectClause ) ! .Add( " FROM " ) ! .Add( fromClause ) ! .Add( outerJoinsAfterFrom ); ! sqlBuilder.Add( " WHERE " ); ! if( whereSqlStrings.Count > 1 ) { sqlBuilder.Add( ! ( SqlString[ ] ) ( ( ArrayList ) whereSqlStrings ).ToArray( typeof( SqlString ) ), ! null, "AND", null, false ); } ! else { ! sqlBuilder.Add( ( SqlString ) whereSqlStrings[ 0 ], null, null, null, false ); } ! sqlBuilder.Add( outerJoinsAfterWhere ); ! ! if( orderByClause != null && orderByClause.Trim().Length > 0 ) { ! sqlBuilder.Add( " ORDER BY " ) ! .Add( orderByClause ); } ! if( log.IsDebugEnabled ) { ! if( initialCapacity < sqlBuilder.Count ) { ! log.Debug( "The initial capacity was set too low at: " + initialCapacity + " for the SelectSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + fromClause ); } ! else if( initialCapacity > 16 && ( ( float ) initialCapacity/sqlBuilder.Count ) > 1.2 ) { log.Debug( "The initial capacity was set too high at: " + initialCapacity + " for the SelectSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + fromClause ); } } *************** *** 228,233 **** } - #endregion } ! } --- 240,245 ---- } + #endregion } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:25:45
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9289 Modified Files: SelectFragment.cs SqlBaseBuilder.cs SqlDeleteBuilder.cs SqlInsertBuilder.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: SqlDeleteBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlDeleteBuilder.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SqlDeleteBuilder.cs 22 Nov 2004 03:56:08 -0000 1.4 --- SqlDeleteBuilder.cs 31 Dec 2004 22:25:33 -0000 1.5 *************** *** 1,32 **** - using System; using System.Collections; ! using System.Text; ! ! using NHibernate.Connection; ! using NHibernate.Dialect; using NHibernate.Engine; - using NHibernate.Util; using NHibernate.Type; ! namespace NHibernate.SqlCommand { /// <summary> /// A class that builds an <c>DELETE</c> sql statement. /// </summary> ! public class SqlDeleteBuilder: SqlBaseBuilder, ISqlStringBuilder { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(SqlDeleteBuilder) ); ! string tableName; ! int versionFragmentIndex = -1; ! int identityFragmentIndex = -1; ! IList whereStrings = new ArrayList(); ! public SqlDeleteBuilder(ISessionFactoryImplementor factory): base(factory) { } ! public SqlDeleteBuilder SetTableName(string tableName) { this.tableName = tableName; --- 1,36 ---- using System.Collections; ! using log4net; using NHibernate.Engine; using NHibernate.Type; ! namespace NHibernate.SqlCommand { /// <summary> /// A class that builds an <c>DELETE</c> sql statement. /// </summary> ! public class SqlDeleteBuilder : SqlBaseBuilder, ISqlStringBuilder { ! private static readonly ILog log = LogManager.GetLogger( typeof( SqlDeleteBuilder ) ); ! private string tableName; ! private int versionFragmentIndex = -1; // not used !?! ! private int identityFragmentIndex = -1; // not used !?! ! private IList whereStrings = new ArrayList(); ! /// <summary> ! /// ! /// </summary> ! /// <param name="factory"></param> ! public SqlDeleteBuilder( ISessionFactoryImplementor factory ) : base( factory ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <returns></returns> ! public SqlDeleteBuilder SetTableName( string tableName ) { this.tableName = tableName; *************** *** 41,49 **** /// <param name="identityType">The IType of the Identity Property.</param> /// <returns>The SqlDeleteBuilder.</returns> ! public SqlDeleteBuilder SetIdentityColumn(string[] columnNames, IType identityType) { ! Parameter[] parameters = Parameter.GenerateParameters( Factory, columnNames, identityType ); ! identityFragmentIndex = whereStrings.Add(ToWhereString(columnNames, parameters)); return this; --- 45,53 ---- /// <param name="identityType">The IType of the Identity Property.</param> /// <returns>The SqlDeleteBuilder.</returns> ! public SqlDeleteBuilder SetIdentityColumn( string[ ] columnNames, IType identityType ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, columnNames, identityType ); ! identityFragmentIndex = whereStrings.Add( ToWhereString( columnNames, parameters ) ); return this; *************** *** 56,64 **** /// <param name="versionType">The IVersionType of the Version Property.</param> /// <returns>The SqlDeleteBuilder.</returns> ! public SqlDeleteBuilder SetVersionColumn(string[] columnNames, IVersionType versionType) { ! Parameter[] parameters = Parameter.GenerateParameters( Factory, columnNames, versionType ); ! versionFragmentIndex = whereStrings.Add(ToWhereString(columnNames, parameters)); return this; --- 60,68 ---- /// <param name="versionType">The IVersionType of the Version Property.</param> /// <returns>The SqlDeleteBuilder.</returns> ! public SqlDeleteBuilder SetVersionColumn( string[ ] columnNames, IVersionType versionType ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, columnNames, versionType ); ! versionFragmentIndex = whereStrings.Add( ToWhereString( columnNames, parameters ) ); return this; *************** *** 72,79 **** /// <param name="op">The operator to put between the column name and value.</param> /// <returns>The SqlDeleteBuilder</returns> ! public SqlDeleteBuilder AddWhereFragment(string[] columnNames, IType type, string op) { ! Parameter[] parameters = Parameter.GenerateParameters( Factory, columnNames, type ); ! whereStrings.Add(ToWhereString(columnNames, parameters, op)); return this; --- 76,83 ---- /// <param name="op">The operator to put between the column name and value.</param> /// <returns>The SqlDeleteBuilder</returns> ! public SqlDeleteBuilder AddWhereFragment( string[ ] columnNames, IType type, string op ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( Factory, columnNames, type ); ! whereStrings.Add( ToWhereString( columnNames, parameters, op ) ); return this; *************** *** 85,91 **** /// <param name="whereString">A well formed sql string with no parameters.</param> /// <returns>The SqlDeleteBuilder</returns> ! public SqlDeleteBuilder AddWhereFragment(string whereString) { ! whereStrings.Add( new SqlString(whereString) ); return this; } --- 89,95 ---- /// <param name="whereString">A well formed sql string with no parameters.</param> /// <returns>The SqlDeleteBuilder</returns> ! public SqlDeleteBuilder AddWhereFragment( string whereString ) { ! whereStrings.Add( new SqlString( whereString ) ); return this; } *************** *** 93,139 **** #region ISqlStringBuilder Members ! public SqlString ToSqlString() { // will for sure have 3 parts and then each item in the WhereStrings ! int initialCapacity = 3; // add an "AND" for each whereString except the first one. ! initialCapacity += (whereStrings.Count -1); ! for( int i=0; i<whereStrings.Count; i++ ) { ! initialCapacity += ((SqlString)whereStrings[i]).Count; } SqlStringBuilder sqlBuilder = new SqlStringBuilder( initialCapacity + 2 ); ! sqlBuilder.Add( "DELETE FROM " ) .Add( tableName ) ! .Add( " WHERE " ); ! ! if(whereStrings.Count > 1) { sqlBuilder.Add( ! (SqlString[])((ArrayList)whereStrings).ToArray(typeof(SqlString)), ! null, "AND", null, false); } ! else { ! sqlBuilder.Add((SqlString)whereStrings[0], null, null, null, false) ; } ! if(log.IsDebugEnabled) { ! if( initialCapacity < sqlBuilder.Count ) { ! log.Debug( "The initial capacity was set too low at: " + initialCapacity + " for the DeleteSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + tableName ); } ! else if( initialCapacity > 16 && ((float)initialCapacity/sqlBuilder.Count) > 1.2 ) { log.Debug( "The initial capacity was set too high at: " + initialCapacity + " for the DeleteSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + tableName); } } --- 97,144 ---- #region ISqlStringBuilder Members ! /// <summary></summary> ! public SqlString ToSqlString() { // will for sure have 3 parts and then each item in the WhereStrings ! int initialCapacity = 3; // add an "AND" for each whereString except the first one. ! initialCapacity += ( whereStrings.Count - 1 ); ! for( int i = 0; i < whereStrings.Count; i++ ) { ! initialCapacity += ( ( SqlString ) whereStrings[ i ] ).Count; } SqlStringBuilder sqlBuilder = new SqlStringBuilder( initialCapacity + 2 ); ! sqlBuilder.Add( "DELETE FROM " ) .Add( tableName ) ! .Add( " WHERE " ); ! ! if( whereStrings.Count > 1 ) { sqlBuilder.Add( ! ( SqlString[ ] ) ( ( ArrayList ) whereStrings ).ToArray( typeof( SqlString ) ), ! null, "AND", null, false ); } ! else { ! sqlBuilder.Add( ( SqlString ) whereStrings[ 0 ], null, null, null, false ); } ! if( log.IsDebugEnabled ) { ! if( initialCapacity < sqlBuilder.Count ) { ! log.Debug( "The initial capacity was set too low at: " + initialCapacity + " for the DeleteSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + tableName ); } ! else if( initialCapacity > 16 && ( ( float ) initialCapacity/sqlBuilder.Count ) > 1.2 ) { log.Debug( "The initial capacity was set too high at: " + initialCapacity + " for the DeleteSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + tableName ); } } *************** *** 143,145 **** #endregion } ! } --- 148,150 ---- #endregion } ! } \ No newline at end of file Index: SelectFragment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SelectFragment.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SelectFragment.cs 21 Sep 2004 09:58:25 -0000 1.6 --- SelectFragment.cs 31 Dec 2004 22:25:33 -0000 1.7 *************** *** 1,6 **** - using System; using System.Collections; using System.Text; - using NHibernate.Util; --- 1,4 ---- *************** *** 17,26 **** private Dialect.Dialect dialect; ! public SelectFragment(Dialect.Dialect d) { this.dialect = d; } ! public SelectFragment SetSuffix(string suffix) { this.suffix = suffix; --- 15,33 ---- private Dialect.Dialect dialect; ! /// <summary> ! /// ! /// </summary> ! /// <param name="d"></param> ! public SelectFragment( Dialect.Dialect d ) { this.dialect = d; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="suffix"></param> ! /// <returns></returns> ! public SelectFragment SetSuffix( string suffix ) { this.suffix = suffix; *************** *** 28,81 **** } ! public SelectFragment AddColumn(string columnName) { ! AddColumn(null, columnName); return this; } ! public SelectFragment AddColumns(string[] columnNames) { ! for (int i=0; i<columnNames.Length; i++) AddColumn(columnNames[i]); return this; } ! public SelectFragment AddColumn(string tableAlias, string columnName) { ! return AddColumn(tableAlias, columnName, columnName); } ! public SelectFragment AddColumn(string tableAlias, string columnName, string columnAlias) { ! if(tableAlias==null || tableAlias.Length == 0) { ! columns.Add(columnName); } ! else { ! columns.Add(tableAlias + StringHelper.Dot + columnName); } ! ! columnAliases.Add(columnAlias); return this; } ! public SelectFragment AddColumns(string tableAlias, string[] columnNames) { ! for (int i=0; i<columnNames.Length; i++) AddColumn(tableAlias, columnNames[i]); return this; } ! public SelectFragment AddColumns(string tableAlias, string[] columnNames, string[] columnAliases) { ! for (int i=0; i<columnNames.Length; i++) ! AddColumn(tableAlias, columnNames[i], columnAliases[i]); return this; } ! ! public SelectFragment AddFormulas(string tableAlias, string[] formulas, string[] formulaAliases) { ! for(int i=0; i < formulas.Length; i++) { ! AddFormula(tableAlias, formulas[i], formulaAliases[i]); } --- 35,139 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="columnName"></param> ! /// <returns></returns> ! public SelectFragment AddColumn( string columnName ) { ! AddColumn( null, columnName ); return this; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="columnNames"></param> ! /// <returns></returns> ! public SelectFragment AddColumns( string[ ] columnNames ) { ! for( int i = 0; i < columnNames.Length; i++ ) ! { ! AddColumn( columnNames[ i ] ); ! } return this; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableAlias"></param> ! /// <param name="columnName"></param> ! /// <returns></returns> ! public SelectFragment AddColumn( string tableAlias, string columnName ) { ! return AddColumn( tableAlias, columnName, columnName ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableAlias"></param> ! /// <param name="columnName"></param> ! /// <param name="columnAlias"></param> ! /// <returns></returns> ! public SelectFragment AddColumn( string tableAlias, string columnName, string columnAlias ) { ! if( tableAlias == null || tableAlias.Length == 0 ) { ! columns.Add( columnName ); } ! else { ! columns.Add( tableAlias + StringHelper.Dot + columnName ); } ! ! columnAliases.Add( columnAlias ); return this; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableAlias"></param> ! /// <param name="columnNames"></param> ! /// <returns></returns> ! public SelectFragment AddColumns( string tableAlias, string[ ] columnNames ) { ! for( int i = 0; i < columnNames.Length; i++ ) ! { ! AddColumn( tableAlias, columnNames[ i ] ); ! } return this; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableAlias"></param> ! /// <param name="columnNames"></param> ! /// <param name="columnAliases"></param> ! /// <returns></returns> ! public SelectFragment AddColumns( string tableAlias, string[ ] columnNames, string[ ] columnAliases ) { ! for( int i = 0; i < columnNames.Length; i++ ) ! { ! AddColumn( tableAlias, columnNames[ i ], columnAliases[ i ] ); ! } return this; } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableAlias"></param> ! /// <param name="formulas"></param> ! /// <param name="formulaAliases"></param> ! /// <returns></returns> ! public SelectFragment AddFormulas( string tableAlias, string[ ] formulas, string[ ] formulaAliases ) { ! for( int i = 0; i < formulas.Length; i++ ) { ! AddFormula( tableAlias, formulas[ i ], formulaAliases[ i ] ); } *************** *** 83,120 **** } ! public SelectFragment AddFormula(string tableAlias, string formula, string formulaAlias) { - AddColumn( ! null, ! StringHelper.Replace(formula, Template.PlaceHolder, tableAlias), ! formulaAlias); return this; } ! ! public SqlString ToSqlStringFragment() { // this preserves the way this existing method works now. ! return ToSqlStringFragment(true); } ! public SqlString ToSqlStringFragment(bool includeLeadingComma) { ! StringBuilder buf = new StringBuilder(columns.Count * 10); ! for (int i=0; i<columns.Count; i++) { ! string col = columns[i] as string; ! if(i > 0 || includeLeadingComma) buf.Append(StringHelper.CommaSpace); ! ! string columnAlias = columnAliases[i] as string; ! buf.Append(col) ! .Append(" as ") ! .Append( new Alias(suffix).ToAliasString(columnAlias, dialect) ); } ! return new SqlString(buf.ToString()); } } ! } --- 141,192 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableAlias"></param> ! /// <param name="formula"></param> ! /// <param name="formulaAlias"></param> ! /// <returns></returns> ! public SelectFragment AddFormula( string tableAlias, string formula, string formulaAlias ) { AddColumn( ! null, ! StringHelper.Replace( formula, Template.PlaceHolder, tableAlias ), ! formulaAlias ); return this; } ! /// <summary></summary> ! public SqlString ToSqlStringFragment() { // this preserves the way this existing method works now. ! return ToSqlStringFragment( true ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="includeLeadingComma"></param> ! /// <returns></returns> ! public SqlString ToSqlStringFragment( bool includeLeadingComma ) { ! StringBuilder buf = new StringBuilder( columns.Count*10 ); ! for( int i = 0; i < columns.Count; i++ ) { ! string col = columns[ i ] as string; ! if( i > 0 || includeLeadingComma ) ! { ! buf.Append( StringHelper.CommaSpace ); ! } ! ! string columnAlias = columnAliases[ i ] as string; ! buf.Append( col ) ! .Append( " as " ) ! .Append( new Alias( suffix ).ToAliasString( columnAlias, dialect ) ); } ! return new SqlString( buf.ToString() ); } } ! } \ No newline at end of file Index: SqlBaseBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlBaseBuilder.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SqlBaseBuilder.cs 22 Nov 2004 03:56:08 -0000 1.4 --- SqlBaseBuilder.cs 31 Dec 2004 22:25:33 -0000 1.5 *************** *** 1,5 **** - using System; - using System.Text; - using NHibernate.Engine; using NHibernate.Util; --- 1,2 ---- *************** *** 10,24 **** /// The base class for all of the SqlBuilders. /// </summary> ! public abstract class SqlBaseBuilder { - private ISessionFactoryImplementor factory; ! protected SqlBaseBuilder(ISessionFactoryImplementor factory) { this.factory = factory; } ! protected ISessionFactoryImplementor Factory { get { return factory; } --- 7,25 ---- /// The base class for all of the SqlBuilders. /// </summary> ! public abstract class SqlBaseBuilder { private ISessionFactoryImplementor factory; ! /// <summary> ! /// ! /// </summary> ! /// <param name="factory"></param> ! protected SqlBaseBuilder( ISessionFactoryImplementor factory ) { this.factory = factory; } ! /// <summary></summary> ! protected ISessionFactoryImplementor Factory { get { return factory; } *************** *** 32,37 **** /// <returns>A SqlString that contains the WhereFragment</returns> /// <remarks>This just calls the overloaded ToWhereFragment() with the operator as " = " and the tableAlias null.</remarks> ! protected SqlString ToWhereString(string[] columnNames, object[] columnValues) { ! return ToWhereString(columnNames, columnValues, " = "); } --- 33,39 ---- /// <returns>A SqlString that contains the WhereFragment</returns> /// <remarks>This just calls the overloaded ToWhereFragment() with the operator as " = " and the tableAlias null.</remarks> ! protected SqlString ToWhereString( string[ ] columnNames, object[ ] columnValues ) ! { ! return ToWhereString( columnNames, columnValues, " = " ); } *************** *** 44,50 **** /// <returns>A SqlString that contains the WhereFragment</returns> /// <remarks>This defaults the op to " = "</remarks> ! protected SqlString ToWhereString(string tableAlias, string[] columnNames, object[] columnValues) { ! return ToWhereString(tableAlias, columnNames, columnValues, " = "); } --- 46,52 ---- /// <returns>A SqlString that contains the WhereFragment</returns> /// <remarks>This defaults the op to " = "</remarks> ! protected SqlString ToWhereString( string tableAlias, string[ ] columnNames, object[ ] columnValues ) { ! return ToWhereString( tableAlias, columnNames, columnValues, " = " ); } *************** *** 56,62 **** /// <param name="op">The operator to use between the names & values. For example " = " or "!="</param> /// <returns>A SqlString that contains the WhereFragment</returns> ! protected SqlString ToWhereString(string[] columnNames, object[] columnValues, string op) { ! return ToWhereString(null, columnNames, columnValues, op); } --- 58,64 ---- /// <param name="op">The operator to use between the names & values. For example " = " or "!="</param> /// <returns>A SqlString that contains the WhereFragment</returns> ! protected SqlString ToWhereString( string[ ] columnNames, object[ ] columnValues, string op ) { ! return ToWhereString( null, columnNames, columnValues, op ); } *************** *** 69,102 **** /// <param name="op">The operator to use between the names & values. For example " = " or "!="</param> /// <returns>A SqlString that contains the WhereFragment</returns> ! protected SqlString ToWhereString(string tableAlias, string[] columnNames, object[] columnValues, string op) { ! SqlStringBuilder sqlBuilder = new SqlStringBuilder((columnNames.Length * 2) + 5); bool andNeeded = false; ! ! for(int i = 0; i < columnNames.Length; i++) { ! if(andNeeded) sqlBuilder.Add(" AND "); andNeeded = true; string columnName; ! if(tableAlias!=null && tableAlias.Length > 0) { ! columnName = tableAlias + StringHelper.Dot + columnNames[i]; } ! else { ! columnName = columnNames[i]; } ! sqlBuilder.Add(columnName) ! .Add(op); ! if(columnValues[i] is Parameter) { ! sqlBuilder.Add((Parameter)columnValues[i]); } ! else { ! sqlBuilder.Add((string)columnValues[i]); } } --- 71,107 ---- /// <param name="op">The operator to use between the names & values. For example " = " or "!="</param> /// <returns>A SqlString that contains the WhereFragment</returns> ! protected SqlString ToWhereString( string tableAlias, string[ ] columnNames, object[ ] columnValues, string op ) { ! SqlStringBuilder sqlBuilder = new SqlStringBuilder( ( columnNames.Length*2 ) + 5 ); bool andNeeded = false; ! ! for( int i = 0; i < columnNames.Length; i++ ) { ! if( andNeeded ) ! { ! sqlBuilder.Add( " AND " ); ! } andNeeded = true; string columnName; ! if( tableAlias != null && tableAlias.Length > 0 ) { ! columnName = tableAlias + StringHelper.Dot + columnNames[ i ]; } ! else { ! columnName = columnNames[ i ]; } ! sqlBuilder.Add( columnName ) ! .Add( op ); ! if( columnValues[ i ] is Parameter ) { ! sqlBuilder.Add( ( Parameter ) columnValues[ i ] ); } ! else { ! sqlBuilder.Add( ( string ) columnValues[ i ] ); } } *************** *** 106,108 **** } } ! } --- 111,113 ---- } } ! } \ No newline at end of file Index: SqlInsertBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlInsertBuilder.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SqlInsertBuilder.cs 4 Dec 2004 22:24:16 -0000 1.4 --- SqlInsertBuilder.cs 31 Dec 2004 22:25:33 -0000 1.5 *************** *** 1,34 **** - using System; using System.Collections; ! using System.Data; ! using System.Text; ! ! using NHibernate.Connection; using NHibernate.Engine; using NHibernate.Type; using NHibernate.Util; ! namespace NHibernate.SqlCommand { /// <summary> /// A class that builds an <c>INSERT</c> sql statement. /// </summary> ! public class SqlInsertBuilder: ISqlStringBuilder { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(SqlInsertBuilder) ); ! private ISessionFactoryImplementor factory; ! string tableName; ! IList columnNames = new ArrayList(); ! IList columnValues = new ArrayList(); //SortedList columnValues = new SortedList(); //key=columName, value=string/IParameter ! public SqlInsertBuilder(ISessionFactoryImplementor factory) { this.factory = factory; } ! public SqlInsertBuilder SetTableName(string tableName) { this.tableName = tableName; --- 1,39 ---- using System.Collections; ! using log4net; using NHibernate.Engine; using NHibernate.Type; using NHibernate.Util; ! namespace NHibernate.SqlCommand { /// <summary> /// A class that builds an <c>INSERT</c> sql statement. /// </summary> ! public class SqlInsertBuilder : ISqlStringBuilder { ! private static readonly ILog log = LogManager.GetLogger( typeof( SqlInsertBuilder ) ); ! private ISessionFactoryImplementor factory; ! private string tableName; ! private IList columnNames = new ArrayList(); ! private IList columnValues = new ArrayList(); //SortedList columnValues = new SortedList(); //key=columName, value=string/IParameter ! /// <summary> ! /// ! /// </summary> ! /// <param name="factory"></param> ! public SqlInsertBuilder( ISessionFactoryImplementor factory ) { this.factory = factory; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <returns></returns> ! public SqlInsertBuilder SetTableName( string tableName ) { this.tableName = tableName; *************** *** 42,55 **** /// <param name="propertyType">The IType of the property.</param> /// <returns>The SqlInsertBuilder.</returns> ! public SqlInsertBuilder AddColumn(string[] columnNames, IType propertyType) { ! Parameter[] parameters = Parameter.GenerateParameters( factory, columnNames, propertyType ); ! for(int i = 0; i < columnNames.Length; i++) { ! this.columnNames.Add(columnNames[i]); ! columnValues.Add(parameters[i]); } ! return this; } --- 47,60 ---- /// <param name="propertyType">The IType of the property.</param> /// <returns>The SqlInsertBuilder.</returns> ! public SqlInsertBuilder AddColumn( string[ ] columnNames, IType propertyType ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( factory, columnNames, propertyType ); ! for( int i = 0; i < columnNames.Length; i++ ) { ! this.columnNames.Add( columnNames[ i ] ); ! columnValues.Add( parameters[ i ] ); } ! return this; } *************** *** 62,68 **** /// <param name="literalType">The NHibernateType to use to convert the value to a sql string.</param> /// <returns>The SqlInsertBuilder.</returns> ! public SqlInsertBuilder AddColumn(string columnName, object val, ILiteralType literalType) { ! return AddColumn(columnName, literalType.ObjectToSQLString(val)); } --- 67,73 ---- /// <param name="literalType">The NHibernateType to use to convert the value to a sql string.</param> /// <returns>The SqlInsertBuilder.</returns> ! public SqlInsertBuilder AddColumn( string columnName, object val, ILiteralType literalType ) { ! return AddColumn( columnName, literalType.ObjectToSQLString( val ) ); } *************** *** 74,89 **** /// <param name="val">A valid sql string to set as the value of the column.</param> /// <returns>The SqlInsertBuilder.</returns> ! public SqlInsertBuilder AddColumn(string columnName, string val) ! { ! columnNames.Add(columnName); ! columnValues.Add(val); ! return this; } ! #region ISqlStringBuilder Members ! public SqlString ToSqlString() ! { // 5 = "INSERT INTO", tableName, " (" , ") VALUES (", and ")" int initialCapacity = 5; --- 79,95 ---- /// <param name="val">A valid sql string to set as the value of the column.</param> /// <returns>The SqlInsertBuilder.</returns> ! public SqlInsertBuilder AddColumn( string columnName, string val ) ! { ! columnNames.Add( columnName ); ! columnValues.Add( val ); ! return this; } ! #region ISqlStringBuilder Members ! /// <summary></summary> ! public SqlString ToSqlString() ! { // 5 = "INSERT INTO", tableName, " (" , ") VALUES (", and ")" int initialCapacity = 5; *************** *** 94,124 **** // eachColumn after the first one is 4 because of the ", ", columnName // and the ", " columnValue ! if( columnNames.Count > 0 ) { ! initialCapacity += ( (columnNames.Count-1) * 4); } SqlStringBuilder sqlBuilder = new SqlStringBuilder( initialCapacity + 2 ); - - sqlBuilder.Add("INSERT INTO ") - .Add(tableName); ! if(columnNames.Count == 0 ) { ! sqlBuilder.Add(" ").Add( factory.Dialect.NoColumnsInsertString ); ! } ! else { ! sqlBuilder.Add(" ("); // do we need a comma before we add the column to the INSERT list // when we get started the first column doesn't need one. bool commaNeeded = false; ! ! foreach(string columnName in columnNames) { // build up the column list ! if(commaNeeded) sqlBuilder.Add(StringHelper.CommaSpace); ! sqlBuilder.Add(columnName); commaNeeded = true; } --- 100,133 ---- // eachColumn after the first one is 4 because of the ", ", columnName // and the ", " columnValue ! if( columnNames.Count > 0 ) { ! initialCapacity += ( ( columnNames.Count - 1 )*4 ); } SqlStringBuilder sqlBuilder = new SqlStringBuilder( initialCapacity + 2 ); ! sqlBuilder.Add( "INSERT INTO " ) ! .Add( tableName ); ! ! if( columnNames.Count == 0 ) { ! sqlBuilder.Add( " " ).Add( factory.Dialect.NoColumnsInsertString ); ! } ! else { ! sqlBuilder.Add( " (" ); // do we need a comma before we add the column to the INSERT list // when we get started the first column doesn't need one. bool commaNeeded = false; ! ! foreach( string columnName in columnNames ) { // build up the column list ! if( commaNeeded ) ! { ! sqlBuilder.Add( StringHelper.CommaSpace ); ! } ! sqlBuilder.Add( columnName ); commaNeeded = true; } *************** *** 127,163 **** commaNeeded = false; ! ! foreach(object obj in columnValues) { ! if(commaNeeded) sqlBuilder.Add(StringHelper.CommaSpace); commaNeeded = true; Parameter param = obj as Parameter; ! if(param!=null) { ! sqlBuilder.Add(param); } ! else { ! sqlBuilder.Add((string)obj); } } ! sqlBuilder.Add(")"); } ! if(log.IsDebugEnabled) { ! if( initialCapacity < sqlBuilder.Count ) { ! log.Debug( "The initial capacity was set too low at: " + initialCapacity + " for the InsertSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + tableName ); } ! else if( initialCapacity > 16 && ((float)initialCapacity/sqlBuilder.Count) > 1.2 ) { log.Debug( "The initial capacity was set too high at: " + initialCapacity + " for the InsertSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + tableName ); } } --- 136,175 ---- commaNeeded = false; ! ! foreach( object obj in columnValues ) { ! if( commaNeeded ) ! { ! sqlBuilder.Add( StringHelper.CommaSpace ); ! } commaNeeded = true; Parameter param = obj as Parameter; ! if( param != null ) { ! sqlBuilder.Add( param ); } ! else { ! sqlBuilder.Add( ( string ) obj ); } } ! sqlBuilder.Add( ")" ); } ! if( log.IsDebugEnabled ) { ! if( initialCapacity < sqlBuilder.Count ) { ! log.Debug( "The initial capacity was set too low at: " + initialCapacity + " for the InsertSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + tableName ); } ! else if( initialCapacity > 16 && ( ( float ) initialCapacity/sqlBuilder.Count ) > 1.2 ) { log.Debug( "The initial capacity was set too high at: " + initialCapacity + " for the InsertSqlBuilder " + ! "that needed a capacity of: " + sqlBuilder.Count + " for the table " + tableName ); } } *************** *** 168,170 **** #endregion } ! } --- 180,182 ---- #endregion } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:25:36
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9247 Modified Files: ParameterLength.cs ParameterPrecisionScale.cs QueryJoinFragment.cs QuerySelect.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: QueryJoinFragment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/QueryJoinFragment.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** QueryJoinFragment.cs 18 Aug 2004 20:43:58 -0000 1.2 --- QueryJoinFragment.cs 31 Dec 2004 22:25:19 -0000 1.3 *************** *** 1,5 **** using System; - - using NHibernate.Dialect; using NHibernate.Engine; using NHibernate.Type; --- 1,3 ---- *************** *** 11,15 **** /// Summary description for QueryJoinFragment. /// </summary> ! public class QueryJoinFragment : JoinFragment { private SqlStringBuilder afterFrom = new SqlStringBuilder(); --- 9,13 ---- /// Summary description for QueryJoinFragment. /// </summary> ! public class QueryJoinFragment : JoinFragment { private SqlStringBuilder afterFrom = new SqlStringBuilder(); *************** *** 17,27 **** private Dialect.Dialect dialect; private bool useThetaStyleInnerJoins; ! ! [Obsolete("Use the ctor with Dialect and bool as the parameters. This will be removed.")] ! public QueryJoinFragment(Dialect.Dialect dialect) : this (dialect, false) { } ! public QueryJoinFragment(Dialect.Dialect dialect, bool useThetaStyleInnerJoins) { this.dialect = dialect; --- 15,34 ---- private Dialect.Dialect dialect; private bool useThetaStyleInnerJoins; ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! [Obsolete( "Use the ctor with Dialect and bool as the parameters. This will be removed." )] ! public QueryJoinFragment( Dialect.Dialect dialect ) : this( dialect, false ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! /// <param name="useThetaStyleInnerJoins"></param> ! public QueryJoinFragment( Dialect.Dialect dialect, bool useThetaStyleInnerJoins ) { this.dialect = dialect; *************** *** 29,71 **** } ! public override void AddJoin(string tableName, string alias, string[] fkColumns, string[] pkColumns, JoinType joinType) { ! AddJoin(tableName, alias, alias, fkColumns, pkColumns, joinType); } ! public void AddJoin(string tableName, string alias, string concreteAlias, string[] fkColumns, string[] pkColumns, JoinType joinType) { ! if (!useThetaStyleInnerJoins || joinType!=JoinType.InnerJoin) { JoinFragment jf = dialect.CreateOuterJoinFragment(); ! jf.AddJoin(tableName, alias, fkColumns, pkColumns, joinType); ! AddFragment(jf); } ! else { ! AddCrossJoin(tableName, alias); ! AddCondition(concreteAlias, fkColumns, pkColumns); } } ! public override SqlString ToFromFragmentString { get { return afterFrom.ToSqlString(); } } ! ! public override SqlString ToWhereFragmentString { get { return afterWhere.ToSqlString(); } } ! public override void AddJoins(SqlString fromFragment, SqlString whereFragment) { ! afterFrom.Add(fromFragment); ! afterWhere.Add(whereFragment); } ! public override JoinFragment Copy() { ! QueryJoinFragment copy = new QueryJoinFragment(dialect, useThetaStyleInnerJoins); copy.afterFrom = new SqlStringBuilder( afterFrom.ToSqlString() ); copy.afterWhere = new SqlStringBuilder( afterWhere.ToSqlString() ); --- 36,103 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <param name="alias"></param> ! /// <param name="fkColumns"></param> ! /// <param name="pkColumns"></param> ! /// <param name="joinType"></param> ! public override void AddJoin( string tableName, string alias, string[ ] fkColumns, string[ ] pkColumns, JoinType joinType ) { ! AddJoin( tableName, alias, alias, fkColumns, pkColumns, joinType ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <param name="alias"></param> ! /// <param name="concreteAlias"></param> ! /// <param name="fkColumns"></param> ! /// <param name="pkColumns"></param> ! /// <param name="joinType"></param> ! public void AddJoin( string tableName, string alias, string concreteAlias, string[ ] fkColumns, string[ ] pkColumns, JoinType joinType ) { ! if( !useThetaStyleInnerJoins || joinType != JoinType.InnerJoin ) { JoinFragment jf = dialect.CreateOuterJoinFragment(); ! jf.AddJoin( tableName, alias, fkColumns, pkColumns, joinType ); ! AddFragment( jf ); } ! else { ! AddCrossJoin( tableName, alias ); ! AddCondition( concreteAlias, fkColumns, pkColumns ); } } ! /// <summary></summary> ! public override SqlString ToFromFragmentString { get { return afterFrom.ToSqlString(); } } ! ! /// <summary></summary> ! public override SqlString ToWhereFragmentString { get { return afterWhere.ToSqlString(); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="fromFragment"></param> ! /// <param name="whereFragment"></param> ! public override void AddJoins( SqlString fromFragment, SqlString whereFragment ) { ! afterFrom.Add( fromFragment ); ! afterWhere.Add( whereFragment ); } ! /// <summary></summary> ! public override JoinFragment Copy() { ! QueryJoinFragment copy = new QueryJoinFragment( dialect, useThetaStyleInnerJoins ); copy.afterFrom = new SqlStringBuilder( afterFrom.ToSqlString() ); copy.afterWhere = new SqlStringBuilder( afterWhere.ToSqlString() ); *************** *** 73,139 **** } ! public override void AddCondition(string alias, string[] columns, string condition) { ! for ( int i=0; i<columns.Length; i++ ) { ! afterWhere.Add(" and " + alias + StringHelper.Dot + columns[i] + condition); } } ! public override void AddCondition(string alias, string[] columns, string condition, IType conditionType, ISessionFactoryImplementor factory) { ! Parameter[] parameters = Parameter.GenerateParameters(factory, alias, columns, conditionType); ! ! for( int i=0; i<columns.Length; i++ ) { ! afterWhere.Add( " and " + alias + StringHelper.Dot + columns[i] + condition ); ! afterWhere.Add( parameters[i] ); } } ! public override void AddCrossJoin(string tableName, string alias) { ! afterFrom.Add(StringHelper.CommaSpace + tableName + ' ' + alias); } ! public override void AddCondition(string alias, string[] fkColumns, string[] pkColumns) { ! for ( int j=0; j<fkColumns.Length; j++) { ! afterWhere.Add( " and " + fkColumns[j] + '=' + alias + StringHelper.Dot + pkColumns[j] ); } } ! public override void AddCondition(string condition) { //TODO: this seems hackish ! if ( afterFrom.ToSqlString().ToString().IndexOf( condition.Trim() ) < 0 && ! afterWhere.ToSqlString().ToString().IndexOf( condition.Trim() ) < 0 ) { ! ! ! if ( !condition.StartsWith(" and ") ) { ! afterWhere.Add(" and "); } ! afterWhere.Add(condition); } } ! ! public override void AddCondition(SqlString condition) { //TODO: this seems hackish if( afterFrom.ToSqlString().ToString().IndexOf( condition.Trim().ToString() ) < 0 && ! afterWhere.ToSqlString().ToString().IndexOf( condition.Trim().ToString() ) < 0 ) { ! if( !condition.StartsWith(" and ") ) { ! afterWhere.Add(" and "); } ! afterWhere.Add(condition); } --- 105,202 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="columns"></param> ! /// <param name="condition"></param> ! public override void AddCondition( string alias, string[ ] columns, string condition ) { ! for( int i = 0; i < columns.Length; i++ ) { ! afterWhere.Add( " and " + alias + StringHelper.Dot + columns[ i ] + condition ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="columns"></param> ! /// <param name="condition"></param> ! /// <param name="conditionType"></param> ! /// <param name="factory"></param> ! public override void AddCondition( string alias, string[ ] columns, string condition, IType conditionType, ISessionFactoryImplementor factory ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( factory, alias, columns, conditionType ); ! ! for( int i = 0; i < columns.Length; i++ ) { ! afterWhere.Add( " and " + alias + StringHelper.Dot + columns[ i ] + condition ); ! afterWhere.Add( parameters[ i ] ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <param name="alias"></param> ! public override void AddCrossJoin( string tableName, string alias ) { ! afterFrom.Add( StringHelper.CommaSpace + tableName + ' ' + alias ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="fkColumns"></param> ! /// <param name="pkColumns"></param> ! public override void AddCondition( string alias, string[ ] fkColumns, string[ ] pkColumns ) { ! for( int j = 0; j < fkColumns.Length; j++ ) { ! afterWhere.Add( " and " + fkColumns[ j ] + '=' + alias + StringHelper.Dot + pkColumns[ j ] ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="condition"></param> ! public override void AddCondition( string condition ) { //TODO: this seems hackish ! if( afterFrom.ToSqlString().ToString().IndexOf( condition.Trim() ) < 0 && ! afterWhere.ToSqlString().ToString().IndexOf( condition.Trim() ) < 0 ) { ! if( !condition.StartsWith( " and " ) ) { ! afterWhere.Add( " and " ); } ! afterWhere.Add( condition ); } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="condition"></param> ! public override void AddCondition( SqlString condition ) { //TODO: this seems hackish if( afterFrom.ToSqlString().ToString().IndexOf( condition.Trim().ToString() ) < 0 && ! afterWhere.ToSqlString().ToString().IndexOf( condition.Trim().ToString() ) < 0 ) { ! if( !condition.StartsWith( " and " ) ) { ! afterWhere.Add( " and " ); } ! afterWhere.Add( condition ); } *************** *** 141,145 **** - } ! } --- 204,207 ---- } ! } \ No newline at end of file Index: ParameterLength.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/ParameterLength.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ParameterLength.cs 9 Aug 2004 03:13:18 -0000 1.7 --- ParameterLength.cs 31 Dec 2004 22:25:19 -0000 1.8 *************** *** 1,6 **** using System; ! namespace NHibernate.SqlCommand ! { /// <summary> /// Extension to the Parameter class that supports Parameters with --- 1,6 ---- using System; ! namespace NHibernate.SqlCommand ! { /// <summary> /// Extension to the Parameter class that supports Parameters with *************** *** 17,43 **** private int length; public int Length { ! get {return length;} ! set {length = value;} } - #region System.Object Members ! ! public override bool Equals(object obj) { ! if(base.Equals(obj)) { ParameterLength rhs; ! // Step 2: Instance of check rhs = obj as ParameterLength; ! if(rhs==null) return false; //Step 3: Check each important field ! return this.Length.Equals(rhs.Length); } ! else { return false; --- 17,51 ---- private int length; + /// <summary></summary> public int Length { ! get { return length; } ! set { length = value; } } #region System.Object Members ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="obj"></param> ! /// <returns></returns> ! public override bool Equals( object obj ) { ! if( base.Equals( obj ) ) { ParameterLength rhs; ! // Step 2: Instance of check rhs = obj as ParameterLength; ! if( rhs == null ) ! { ! return false; ! } //Step 3: Check each important field ! return this.Length.Equals( rhs.Length ); } ! else { return false; *************** *** 45,51 **** } public override int GetHashCode() { ! unchecked { return base.GetHashCode() + length.GetHashCode(); --- 53,60 ---- } + /// <summary></summary> public override int GetHashCode() { ! unchecked { return base.GetHashCode() + length.GetHashCode(); *************** *** 54,58 **** #endregion - } ! } --- 63,66 ---- #endregion } ! } \ No newline at end of file Index: QuerySelect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/QuerySelect.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** QuerySelect.cs 4 Dec 2004 22:41:30 -0000 1.3 --- QuerySelect.cs 31 Dec 2004 22:25:19 -0000 1.4 *************** *** 1,9 **** - using System; - using System.Text; using System.Collections; ! using Iesi.Collections; - - using NHibernate.Dialect; using NHibernate.Util; --- 1,5 ---- using System.Collections; ! using System.Text; using Iesi.Collections; using NHibernate.Util; *************** *** 13,25 **** /// Summary description for QuerySelect. /// </summary> ! public class QuerySelect ! { private JoinFragment joins; ! // the selectBuilder could probably be a string if the Persister's methods that build // the SqlString instead returned a String. private SqlStringBuilder selectBuilder = new SqlStringBuilder(); private SqlStringBuilder whereBuilder = new SqlStringBuilder(); ! // groupBy, orderBy, and having will for sure have no parameters. private StringBuilder groupBy = new StringBuilder(); --- 9,21 ---- /// Summary description for QuerySelect. /// </summary> ! public class QuerySelect ! { private JoinFragment joins; ! // the selectBuilder could probably be a string if the Persister's methods that build // the SqlString instead returned a String. private SqlStringBuilder selectBuilder = new SqlStringBuilder(); private SqlStringBuilder whereBuilder = new SqlStringBuilder(); ! // groupBy, orderBy, and having will for sure have no parameters. private StringBuilder groupBy = new StringBuilder(); *************** *** 40,44 **** private static readonly ISet dontSpace = new HashedSet(); ! static QuerySelect() { //dontSpace.add("'"); --- 36,41 ---- private static readonly ISet dontSpace = new HashedSet(); ! /// <summary></summary> ! static QuerySelect() { //dontSpace.add("'"); *************** *** 66,70 **** dontSpace.Add( "!>" ); // MySQL doesn't like spaces around "(" or ")" also. ! dontSpace.Add( StringHelper.OpenParen ); dontSpace.Add( StringHelper.ClosedParen ); --- 63,67 ---- dontSpace.Add( "!>" ); // MySQL doesn't like spaces around "(" or ")" also. ! dontSpace.Add( StringHelper.OpenParen ); dontSpace.Add( StringHelper.ClosedParen ); *************** *** 92,218 **** dontSpace.Add( new SqlString( "!>" ) ); // MySQL doesn't like spaces around "(" or ")" also. ! dontSpace.Add( new SqlString( StringHelper.OpenParen ) ); dontSpace.Add( new SqlString( StringHelper.ClosedParen ) ); } ! public QuerySelect(Dialect.Dialect dialect) { ! joins = new QueryJoinFragment(dialect, false); } ! public JoinFragment JoinFragment { get { return joins; } } ! ! public void AddSelectFragmentString(string fragment) { ! AddSelectFragmentString( new SqlString(fragment) ); } ! ! public void AddSelectFragmentString(SqlString fragment) { ! if( fragment.SqlParts.Length>0 && fragment.StartsWith(",") ) { ! fragment = fragment.Substring(1); } fragment = fragment.Trim(); ! if( fragment.SqlParts.Length > 0 ) { ! if( selectBuilder.Count > 0 ) { ! selectBuilder.Add(StringHelper.CommaSpace); } ! ! selectBuilder.Add(fragment); } } ! public void AddSelectColumn(string columnName, string alias) { ! AddSelectFragmentString(columnName + ' ' + alias); } ! ! public bool Distinct { get { return distinct; } set { this.distinct = value; } } ! ! public void SetWhereTokens(ICollection tokens) { //if ( conjunctiveWhere.length()>0 ) conjunctiveWhere.append(" and "); ! AppendTokens(whereBuilder, tokens); //AppendTokens(where, tokens); } ! ! public void SetGroupByTokens(ICollection tokens) { //if ( groupBy.length()>0 ) groupBy.append(" and "); ! AppendTokens(groupBy, tokens); } ! ! public void SetOrderByTokens(ICollection tokens) { //if ( orderBy.length()>0 ) orderBy.append(" and "); ! AppendTokens(orderBy, tokens); } ! ! public void SetHavingTokens(ICollection tokens) { //if ( having.length()>0 ) having.append(" and "); ! AppendTokens(having, tokens); } ! public void AddOrderBy(string orderByString) { ! if( orderBy.Length > 0 ) orderBy.Append(StringHelper.CommaSpace); ! orderBy.Append(orderByString); } ! public SqlString ToQuerySqlString() { SqlStringBuilder builder = new SqlStringBuilder(); - - builder.Add("select "); ! if (distinct) builder.Add("distinct "); ! SqlString from = joins.ToFromFragmentString; ! if ( from.StartsWith(",") ) { ! from = from.Substring(1); } ! else if ( from.StartsWith(" inner join") ) { ! from = from.Substring(11); } ! builder.Add(selectBuilder.ToSqlString()) ! .Add(" from") .Add( from ); ! SqlString part1 = joins.ToWhereFragmentString.Trim(); ! SqlString part2 = whereBuilder.ToSqlString().Trim(); bool hasPart1 = part1.SqlParts.Length > 0; bool hasPart2 = part2.SqlParts.Length > 0; ! ! if (hasPart1 || hasPart2) builder.Add(" where "); ! if (hasPart1) builder.Add( part1.Substring(4) ); ! if (hasPart2) { ! if (hasPart1) builder.Add(" and ("); ! builder.Add(part2); ! if (hasPart1) builder.Add(")"); } - if ( groupBy.Length > 0 ) builder.Add(" group by ").Add( groupBy.ToString() ); - if ( having.Length > 0 ) builder.Add(" having ").Add( having.ToString() ); - if ( orderBy.Length > 0 ) builder.Add(" order by ").Add( orderBy.ToString() ); return builder.ToSqlString(); } ! private void AppendTokens(StringBuilder buf, ICollection iter) { bool lastSpaceable = true; --- 89,287 ---- dontSpace.Add( new SqlString( "!>" ) ); // MySQL doesn't like spaces around "(" or ")" also. ! dontSpace.Add( new SqlString( StringHelper.OpenParen ) ); dontSpace.Add( new SqlString( StringHelper.ClosedParen ) ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! public QuerySelect( Dialect.Dialect dialect ) { ! joins = new QueryJoinFragment( dialect, false ); } ! /// <summary></summary> ! public JoinFragment JoinFragment { get { return joins; } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="fragment"></param> ! public void AddSelectFragmentString( string fragment ) { ! AddSelectFragmentString( new SqlString( fragment ) ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="fragment"></param> ! public void AddSelectFragmentString( SqlString fragment ) { ! if( fragment.SqlParts.Length > 0 && fragment.StartsWith( "," ) ) { ! fragment = fragment.Substring( 1 ); } fragment = fragment.Trim(); ! if( fragment.SqlParts.Length > 0 ) { ! if( selectBuilder.Count > 0 ) { ! selectBuilder.Add( StringHelper.CommaSpace ); } ! ! selectBuilder.Add( fragment ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="columnName"></param> ! /// <param name="alias"></param> ! public void AddSelectColumn( string columnName, string alias ) { ! AddSelectFragmentString( columnName + ' ' + alias ); } ! ! /// <summary></summary> ! public bool Distinct { get { return distinct; } set { this.distinct = value; } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="tokens"></param> ! public void SetWhereTokens( ICollection tokens ) { //if ( conjunctiveWhere.length()>0 ) conjunctiveWhere.append(" and "); ! AppendTokens( whereBuilder, tokens ); //AppendTokens(where, tokens); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="tokens"></param> ! public void SetGroupByTokens( ICollection tokens ) { //if ( groupBy.length()>0 ) groupBy.append(" and "); ! AppendTokens( groupBy, tokens ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="tokens"></param> ! public void SetOrderByTokens( ICollection tokens ) { //if ( orderBy.length()>0 ) orderBy.append(" and "); ! AppendTokens( orderBy, tokens ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="tokens"></param> ! public void SetHavingTokens( ICollection tokens ) { //if ( having.length()>0 ) having.append(" and "); ! AppendTokens( having, tokens ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="orderByString"></param> ! public void AddOrderBy( string orderByString ) { ! if( orderBy.Length > 0 ) ! { ! orderBy.Append( StringHelper.CommaSpace ); ! } ! orderBy.Append( orderByString ); } ! /// <summary></summary> ! public SqlString ToQuerySqlString() { SqlStringBuilder builder = new SqlStringBuilder(); ! builder.Add( "select " ); ! ! if( distinct ) ! { ! builder.Add( "distinct " ); ! } ! SqlString from = joins.ToFromFragmentString; ! if( from.StartsWith( "," ) ) { ! from = from.Substring( 1 ); } ! else if( from.StartsWith( " inner join" ) ) { ! from = from.Substring( 11 ); } ! builder.Add( selectBuilder.ToSqlString() ) ! .Add( " from" ) .Add( from ); ! SqlString part1 = joins.ToWhereFragmentString.Trim(); ! SqlString part2 = whereBuilder.ToSqlString().Trim(); bool hasPart1 = part1.SqlParts.Length > 0; bool hasPart2 = part2.SqlParts.Length > 0; ! ! if( hasPart1 || hasPart2 ) { ! builder.Add( " where " ); ! } ! if( hasPart1 ) ! { ! builder.Add( part1.Substring( 4 ) ); ! } ! if( hasPart2 ) ! { ! if( hasPart1 ) ! { ! builder.Add( " and (" ); ! } ! builder.Add( part2 ); ! if( hasPart1 ) ! { ! builder.Add( ")" ); ! } ! } ! if( groupBy.Length > 0 ) ! { ! builder.Add( " group by " ).Add( groupBy.ToString() ); ! } ! if( having.Length > 0 ) ! { ! builder.Add( " having " ).Add( having.ToString() ); ! } ! if( orderBy.Length > 0 ) ! { ! builder.Add( " order by " ).Add( orderBy.ToString() ); } return builder.ToSqlString(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="buf"></param> ! /// <param name="iter"></param> ! private void AppendTokens( StringBuilder buf, ICollection iter ) { bool lastSpaceable = true; *************** *** 220,241 **** int debugIndex = 0; ! foreach(string token in iter) { ! bool spaceable = !dontSpace.Contains(token); ! bool quoted = token.StartsWith("'"); ! if (spaceable && lastSpaceable) { ! if (!quoted || !lastQuoted) buf.Append(' '); } lastSpaceable = spaceable; ! buf.Append(token); ! lastQuoted = token.EndsWith("'"); debugIndex++; } } ! private void AppendTokens(SqlStringBuilder builder, ICollection iter) { bool lastSpaceable = true; --- 289,318 ---- int debugIndex = 0; ! foreach( string token in iter ) { ! bool spaceable = !dontSpace.Contains( token ); ! bool quoted = token.StartsWith( "'" ); ! if( spaceable && lastSpaceable ) { ! if( !quoted || !lastQuoted ) ! { ! buf.Append( ' ' ); ! } } lastSpaceable = spaceable; ! buf.Append( token ); ! lastQuoted = token.EndsWith( "'" ); debugIndex++; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="builder"></param> ! /// <param name="iter"></param> ! private void AppendTokens( SqlStringBuilder builder, ICollection iter ) { bool lastSpaceable = true; *************** *** 243,293 **** int debugIndex = 0; ! foreach(object token in iter) { string tokenString = token as string; SqlString tokenSqlString = token as SqlString; ! bool spaceable = !dontSpace.Contains(token); bool quoted = false; //TODO: seems HACKish to cast between String and SqlString ! if(tokenString!=null) { ! quoted = tokenString.StartsWith("'"); } ! else { ! quoted = tokenSqlString.StartsWith("'"); } ! if (spaceable && lastSpaceable) { ! if (!quoted || !lastQuoted) builder.Add(" "); } lastSpaceable = spaceable; ! ! if( token.Equals(StringHelper.SqlParameter) ) { Parameter param = new Parameter(); param.Name = "placholder"; ! builder.Add(param); } ! else { // not sure if we have a string or a SqlString here and token is a // reference to an object - so let the builder figure out what the // actual object is ! builder.AddObject(token); } debugIndex++; ! if( tokenString!=null ) { ! lastQuoted = tokenString.EndsWith("'"); } ! else { ! lastQuoted = tokenSqlString.EndsWith("'"); } } --- 320,373 ---- int debugIndex = 0; ! foreach( object token in iter ) { string tokenString = token as string; SqlString tokenSqlString = token as SqlString; ! bool spaceable = !dontSpace.Contains( token ); bool quoted = false; //TODO: seems HACKish to cast between String and SqlString ! if( tokenString != null ) { ! quoted = tokenString.StartsWith( "'" ); } ! else { ! quoted = tokenSqlString.StartsWith( "'" ); } ! if( spaceable && lastSpaceable ) { ! if( !quoted || !lastQuoted ) ! { ! builder.Add( " " ); ! } } lastSpaceable = spaceable; ! ! if( token.Equals( StringHelper.SqlParameter ) ) { Parameter param = new Parameter(); param.Name = "placholder"; ! builder.Add( param ); } ! else { // not sure if we have a string or a SqlString here and token is a // reference to an object - so let the builder figure out what the // actual object is ! builder.AddObject( token ); } debugIndex++; ! if( tokenString != null ) { ! lastQuoted = tokenString.EndsWith( "'" ); } ! else { ! lastQuoted = tokenSqlString.EndsWith( "'" ); } } Index: ParameterPrecisionScale.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/ParameterPrecisionScale.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ParameterPrecisionScale.cs 9 Aug 2004 03:13:18 -0000 1.7 --- ParameterPrecisionScale.cs 31 Dec 2004 22:25:19 -0000 1.8 *************** *** 1,6 **** using System; ! namespace NHibernate.SqlCommand ! { /// <summary> /// Extension to the Parameter class that supports Parameters with --- 1,6 ---- using System; ! namespace NHibernate.SqlCommand ! { /// <summary> /// Extension to the Parameter class that supports Parameters with *************** *** 13,51 **** /// </remarks> [Serializable] ! public class ParameterPrecisionScale : Parameter { private byte precision; private byte scale; ! public byte Precision { ! get {return precision;} ! set {precision = value;} } ! public byte Scale { ! get {return scale;} ! set {scale = value;} } - #region System.Object Members ! ! public override bool Equals(object obj) { ! if(base.Equals(obj)) { ParameterPrecisionScale rhs; ! // Step 2: Instance of check rhs = obj as ParameterPrecisionScale; ! if(rhs==null) return false; //Step 3: Check each important field ! return this.Precision==rhs.Precision ! && this.Scale==rhs.Scale; } ! else { return false; --- 13,60 ---- /// </remarks> [Serializable] ! public class ParameterPrecisionScale : Parameter { private byte precision; private byte scale; ! /// <summary></summary> ! public byte Precision { ! get { return precision; } ! set { precision = value; } } ! /// <summary></summary> ! public byte Scale { ! get { return scale; } ! set { scale = value; } } #region System.Object Members ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="obj"></param> ! /// <returns></returns> ! public override bool Equals( object obj ) { ! if( base.Equals( obj ) ) { ParameterPrecisionScale rhs; ! // Step 2: Instance of check rhs = obj as ParameterPrecisionScale; ! if( rhs == null ) ! { ! return false; ! } //Step 3: Check each important field ! return this.Precision == rhs.Precision ! && this.Scale == rhs.Scale; } ! else { return false; *************** *** 53,59 **** } public override int GetHashCode() { ! unchecked { return base.GetHashCode() + precision.GetHashCode() + scale.GetHashCode(); --- 62,69 ---- } + /// <summary></summary> public override int GetHashCode() { ! unchecked { return base.GetHashCode() + precision.GetHashCode() + scale.GetHashCode(); *************** *** 62,67 **** #endregion - } ! } ! --- 72,75 ---- #endregion } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:25:12
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9172 Modified Files: ISqlStringBuilder.cs JoinFragment.cs OracleJoinFragment.cs Parameter.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: ISqlStringBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/ISqlStringBuilder.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ISqlStringBuilder.cs 22 Nov 2004 03:56:00 -0000 1.2 --- ISqlStringBuilder.cs 31 Dec 2004 22:25:00 -0000 1.3 *************** *** 1,11 **** ! using System; ! ! using NHibernate.Dialect; ! using NHibernate.Connection; ! ! namespace NHibernate.SqlCommand { ! ! public interface ISqlStringBuilder { /// <summary> --- 1,6 ---- ! namespace NHibernate.SqlCommand { ! /// <summary></summary> ! public interface ISqlStringBuilder { /// <summary> *************** *** 15,17 **** SqlString ToSqlString(); } ! } --- 10,12 ---- SqlString ToSqlString(); } ! } \ No newline at end of file Index: JoinFragment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/JoinFragment.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JoinFragment.cs 18 Aug 2004 20:43:58 -0000 1.2 --- JoinFragment.cs 31 Dec 2004 22:25:00 -0000 1.3 *************** *** 1,4 **** using System; - using NHibernate.Engine; using NHibernate.Type; --- 1,3 ---- *************** *** 6,15 **** namespace NHibernate.SqlCommand { ! public enum JoinType { None = -666, InnerJoin = 0, FullJoin = -1, LeftOuterJoin = 1, RightOuterJoin = 2 } --- 5,20 ---- namespace NHibernate.SqlCommand { ! /// <summary></summary> ! public enum JoinType { + /// <summary></summary> None = -666, + /// <summary></summary> InnerJoin = 0, + /// <summary></summary> FullJoin = -1, + /// <summary></summary> LeftOuterJoin = 1, + /// <summary></summary> RightOuterJoin = 2 } *************** *** 20,47 **** public abstract class JoinFragment { ! public abstract void AddJoin(string tableName, string alias, string[] fkColumns, string[] pkColumns, JoinType joinType); ! public abstract void AddCrossJoin(string tableName, string alias); ! public abstract void AddJoins(SqlString fromFragment, SqlString whereFragment); public abstract SqlString ToFromFragmentString { get; } public abstract SqlString ToWhereFragmentString { get; } ! public abstract void AddCondition(string alias, string[] columns, string condition); ! public abstract void AddCondition(string alias, string[] columns, string condition, IType conditionType, ISessionFactoryImplementor factory); ! public abstract void AddCondition(string alias, string[] fkColumns, string[] pkColumns); ! public abstract void AddCondition(string condition); ! public abstract void AddCondition(SqlString condition); public abstract JoinFragment Copy(); ! public virtual void AddFragment(JoinFragment ojf) { AddJoins( ojf.ToFromFragmentString, ojf.ToWhereFragmentString ); } ! [Obsolete("should use SqlString instead")] ! public virtual void AddJoins(string fromFragment, string whereFragment) { ! this.AddJoins( new SqlString(fromFragment), new SqlString(whereFragment) ); } } ! } --- 25,118 ---- public abstract class JoinFragment { ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <param name="alias"></param> ! /// <param name="fkColumns"></param> ! /// <param name="pkColumns"></param> ! /// <param name="joinType"></param> ! public abstract void AddJoin( string tableName, string alias, string[ ] fkColumns, string[ ] pkColumns, JoinType joinType ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <param name="alias"></param> ! public abstract void AddCrossJoin( string tableName, string alias ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="fromFragment"></param> ! /// <param name="whereFragment"></param> ! public abstract void AddJoins( SqlString fromFragment, SqlString whereFragment ); ! ! /// <summary></summary> public abstract SqlString ToFromFragmentString { get; } + + /// <summary></summary> public abstract SqlString ToWhereFragmentString { get; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="columns"></param> ! /// <param name="condition"></param> ! public abstract void AddCondition( string alias, string[ ] columns, string condition ); + /// <summary> + /// + /// </summary> + /// <param name="alias"></param> + /// <param name="columns"></param> + /// <param name="condition"></param> + /// <param name="conditionType"></param> + /// <param name="factory"></param> + public abstract void AddCondition( string alias, string[ ] columns, string condition, IType conditionType, ISessionFactoryImplementor factory ); + + /// <summary> + /// + /// </summary> + /// <param name="alias"></param> + /// <param name="fkColumns"></param> + /// <param name="pkColumns"></param> + public abstract void AddCondition( string alias, string[ ] fkColumns, string[ ] pkColumns ); + + /// <summary> + /// + /// </summary> + /// <param name="condition"></param> + public abstract void AddCondition( string condition ); + + /// <summary> + /// + /// </summary> + /// <param name="condition"></param> + public abstract void AddCondition( SqlString condition ); + + /// <summary></summary> public abstract JoinFragment Copy(); ! /// <summary> ! /// ! /// </summary> ! /// <param name="ojf"></param> ! public virtual void AddFragment( JoinFragment ojf ) { AddJoins( ojf.ToFromFragmentString, ojf.ToWhereFragmentString ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="fromFragment"></param> ! /// <param name="whereFragment"></param> ! [Obsolete( "should use SqlString instead" )] ! public virtual void AddJoins( string fromFragment, string whereFragment ) { ! this.AddJoins( new SqlString( fromFragment ), new SqlString( whereFragment ) ); } } ! } \ No newline at end of file Index: OracleJoinFragment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/OracleJoinFragment.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OracleJoinFragment.cs 18 Aug 2004 20:43:58 -0000 1.2 --- OracleJoinFragment.cs 31 Dec 2004 22:25:00 -0000 1.3 *************** *** 1,4 **** using System; - using NHibernate.Engine; using NHibernate.Type; --- 1,3 ---- *************** *** 15,50 **** private SqlStringBuilder afterWhere = new SqlStringBuilder(); ! public override void AddJoin(string tableName, string alias, string[] fkColumns, string[] pkColumns, JoinType joinType) { ! AddCrossJoin(tableName, alias); ! for (int j=0; j<fkColumns.Length; j++) { ! afterWhere.Add( " and " + fkColumns[j] ); ! if (joinType == JoinType.RightOuterJoin || joinType == JoinType.FullJoin) afterWhere.Add("(+)"); ! ! afterWhere.Add( "=" + alias + StringHelper.Dot + pkColumns[j] ); ! if (joinType == JoinType.LeftOuterJoin || joinType == JoinType.FullJoin) afterWhere.Add("(+)"); } } ! public override SqlString ToFromFragmentString { get { return afterFrom.ToSqlString(); } } ! public override SqlString ToWhereFragmentString { get { return afterWhere.ToSqlString(); } } ! public override void AddJoins(SqlString fromFragment, SqlString whereFragment) { ! afterFrom.Add(fromFragment); ! afterWhere.Add(whereFragment); } ! public override JoinFragment Copy() { OracleJoinFragment copy = new OracleJoinFragment(); --- 14,71 ---- private SqlStringBuilder afterWhere = new SqlStringBuilder(); ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <param name="alias"></param> ! /// <param name="fkColumns"></param> ! /// <param name="pkColumns"></param> ! /// <param name="joinType"></param> ! public override void AddJoin( string tableName, string alias, string[ ] fkColumns, string[ ] pkColumns, JoinType joinType ) { ! AddCrossJoin( tableName, alias ); ! for( int j = 0; j < fkColumns.Length; j++ ) { ! afterWhere.Add( " and " + fkColumns[ j ] ); ! if( joinType == JoinType.RightOuterJoin || joinType == JoinType.FullJoin ) ! { ! afterWhere.Add( "(+)" ); ! } ! afterWhere.Add( "=" + alias + StringHelper.Dot + pkColumns[ j ] ); ! ! if( joinType == JoinType.LeftOuterJoin || joinType == JoinType.FullJoin ) ! { ! afterWhere.Add( "(+)" ); ! } } } ! /// <summary></summary> ! public override SqlString ToFromFragmentString { get { return afterFrom.ToSqlString(); } } ! /// <summary></summary> ! public override SqlString ToWhereFragmentString { get { return afterWhere.ToSqlString(); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="fromFragment"></param> ! /// <param name="whereFragment"></param> ! public override void AddJoins( SqlString fromFragment, SqlString whereFragment ) { ! afterFrom.Add( fromFragment ); ! afterWhere.Add( whereFragment ); } ! /// <summary></summary> ! public override JoinFragment Copy() { OracleJoinFragment copy = new OracleJoinFragment(); *************** *** 54,94 **** } ! public override void AddCondition(string alias, string[] columns, string condition) { ! for (int i=0; i<columns.Length; i++) { ! afterWhere.Add(" and " + alias + StringHelper.Dot + columns[i] + condition ); } } ! public override void AddCondition(string alias, string[] columns, string condition, IType conditionType, ISessionFactoryImplementor factory) { ! Parameter[] parameters = Parameter.GenerateParameters(factory, alias, columns, conditionType); ! for( int i=0; i<columns.Length; i++) { ! afterWhere.Add( " and " + alias + StringHelper.Dot + columns[i] + condition ); ! afterWhere.Add( parameters[i] ); } } ! public override void AddCrossJoin(string tableName, string alias) { ! afterFrom.Add(StringHelper.CommaSpace + tableName + " " + alias); } ! public override void AddCondition(string alias, string[] fkColumns, string[] pkColumns) { throw new NotSupportedException(); } ! ! ! ! public override void AddCondition(string condition) { throw new NotSupportedException(); } ! public override void AddCondition(SqlString condition) { throw new NotSupportedException(); --- 75,145 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="columns"></param> ! /// <param name="condition"></param> ! public override void AddCondition( string alias, string[ ] columns, string condition ) { ! for( int i = 0; i < columns.Length; i++ ) { ! afterWhere.Add( " and " + alias + StringHelper.Dot + columns[ i ] + condition ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="columns"></param> ! /// <param name="condition"></param> ! /// <param name="conditionType"></param> ! /// <param name="factory"></param> ! public override void AddCondition( string alias, string[ ] columns, string condition, IType conditionType, ISessionFactoryImplementor factory ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( factory, alias, columns, conditionType ); ! for( int i = 0; i < columns.Length; i++ ) { ! afterWhere.Add( " and " + alias + StringHelper.Dot + columns[ i ] + condition ); ! afterWhere.Add( parameters[ i ] ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <param name="alias"></param> ! public override void AddCrossJoin( string tableName, string alias ) { ! afterFrom.Add( StringHelper.CommaSpace + tableName + " " + alias ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="fkColumns"></param> ! /// <param name="pkColumns"></param> ! public override void AddCondition( string alias, string[ ] fkColumns, string[ ] pkColumns ) { throw new NotSupportedException(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="condition"></param> ! public override void AddCondition( string condition ) { throw new NotSupportedException(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="condition"></param> ! public override void AddCondition( SqlString condition ) { throw new NotSupportedException(); *************** *** 96,98 **** } ! } --- 147,149 ---- } ! } \ No newline at end of file Index: Parameter.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/Parameter.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Parameter.cs 4 Dec 2004 22:41:29 -0000 1.11 --- Parameter.cs 31 Dec 2004 22:25:00 -0000 1.12 *************** *** 1,11 **** - using System; //using System.Data; - //using NHibernate.Driver; using NHibernate.Engine; using NHibernate.SqlTypes; using NHibernate.Type; - namespace NHibernate.SqlCommand { --- 1,9 ---- //using System.Data; //using NHibernate.Driver; + using System; using NHibernate.Engine; using NHibernate.SqlTypes; using NHibernate.Type; namespace NHibernate.SqlCommand { *************** *** 15,39 **** /// </summary> [Serializable] ! public class Parameter: ICloneable { private string tableAlias; private string name; private SqlType _sqlType; ! ! public string Name { ! get{ return name;} ! set{ this.name = value;} } ! ! public string TableAlias { ! get {return tableAlias;} ! set {this.tableAlias = value;} } ! ! public SqlType SqlType { get { return _sqlType; } --- 13,38 ---- /// </summary> [Serializable] ! public class Parameter : ICloneable { private string tableAlias; private string name; private SqlType _sqlType; ! ! /// <summary></summary> ! public string Name { ! get { return name; } ! set { this.name = value; } } ! /// <summary></summary> ! public string TableAlias { ! get { return tableAlias; } ! set { this.tableAlias = value; } } ! /// <summary></summary> ! public SqlType SqlType { get { return _sqlType; } *************** *** 47,54 **** /// <param name="columnNames">The names of the Columns that compose the IType</param> /// <param name="type">The IType to turn into Parameters</param> /// <returns>An Array of IParameter objects</returns> ! public static Parameter[] GenerateParameters(ISessionFactoryImplementor factory, string[] columnNames, IType type) { ! return Parameter.GenerateParameters(factory, null, columnNames, type); } --- 46,54 ---- /// <param name="columnNames">The names of the Columns that compose the IType</param> /// <param name="type">The IType to turn into Parameters</param> + /// <param name="factory"></param> /// <returns>An Array of IParameter objects</returns> ! public static Parameter[ ] GenerateParameters( ISessionFactoryImplementor factory, string[ ] columnNames, IType type ) { ! return Parameter.GenerateParameters( factory, null, columnNames, type ); } *************** *** 62,90 **** /// <param name="type">The IType to turn into Parameters</param> /// <returns>An Array of IParameter objects</returns> ! public static Parameter[] GenerateParameters(ISessionFactoryImplementor factory, string tableAlias, string[] columnNames, IType type) { ! SqlType[] sqlTypes = type.SqlTypes(factory); ! Parameter[] parameters = new Parameter[sqlTypes.Length]; ! for(int i = 0; i < sqlTypes.Length; i++) { ! if(sqlTypes[i].LengthDefined) { ParameterLength param = new ParameterLength(); ! param.Length = sqlTypes[i].Length; ! parameters[i] = param; } ! else if(sqlTypes[i].PrecisionDefined) { ParameterPrecisionScale param = new ParameterPrecisionScale(); ! param.Precision = sqlTypes[i].Precision; ! param.Scale = sqlTypes[i].Scale; ! parameters[i] = param; } ! else { ! parameters[i] = new Parameter(); } ! parameters[i].Name = columnNames[i]; ! parameters[i].TableAlias = tableAlias; ! parameters[i].SqlType = sqlTypes[i]; } --- 62,94 ---- /// <param name="type">The IType to turn into Parameters</param> /// <returns>An Array of IParameter objects</returns> ! public static Parameter[ ] GenerateParameters( ISessionFactoryImplementor factory, string tableAlias, string[ ] columnNames, IType type ) { ! SqlType[ ] sqlTypes = type.SqlTypes( factory ); ! Parameter[ ] parameters = new Parameter[sqlTypes.Length]; ! for( int i = 0; i < sqlTypes.Length; i++ ) ! { ! if( sqlTypes[ i ].LengthDefined ) ! { ParameterLength param = new ParameterLength(); ! param.Length = sqlTypes[ i ].Length; ! parameters[ i ] = param; } ! else if( sqlTypes[ i ].PrecisionDefined ) ! { ParameterPrecisionScale param = new ParameterPrecisionScale(); ! param.Precision = sqlTypes[ i ].Precision; ! param.Scale = sqlTypes[ i ].Scale; ! parameters[ i ] = param; } ! else ! { ! parameters[ i ] = new Parameter(); } ! parameters[ i ].Name = columnNames[ i ]; ! parameters[ i ].TableAlias = tableAlias; ! parameters[ i ].SqlType = sqlTypes[ i ]; } *************** *** 95,115 **** #region object Members ! ! public override bool Equals(object obj) { Parameter rhs; ! // Step1: Perform an equals test ! if(obj==this) return true; // Step 2: Instance of check rhs = obj as Parameter; ! if(rhs==null) return false; //Step 3: Check each important field ! // these 2 fields will not be null so compare them... ! if( this.SqlType.Equals(rhs.SqlType)==false ! || this.Name.Equals(rhs.Name)==false) { return false; --- 99,129 ---- #region object Members ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="obj"></param> ! /// <returns></returns> ! public override bool Equals( object obj ) { Parameter rhs; ! // Step1: Perform an equals test ! if( obj == this ) ! { ! return true; ! } // Step 2: Instance of check rhs = obj as Parameter; ! if( rhs == null ) ! { ! return false; ! } //Step 3: Check each important field ! // these 2 fields will not be null so compare them... ! if( this.SqlType.Equals( rhs.SqlType ) == false || this.Name.Equals( rhs.Name ) == false ) { return false; *************** *** 117,149 **** // becareful with TableAlias being null ! if(this.TableAlias==null && rhs.TableAlias==null) { return true; } ! else if (this.TableAlias==null && rhs.TableAlias!=null) { return false; } ! else { ! return this.TableAlias.Equals(rhs.TableAlias); } } public override int GetHashCode() { int hashCode = 0; ! unchecked { ! if( _sqlType!=null ) { hashCode += _sqlType.GetHashCode(); } ! if( name!=null ) { hashCode += name.GetHashCode(); } ! if(tableAlias!=null) { hashCode += tableAlias.GetHashCode(); --- 131,167 ---- // becareful with TableAlias being null ! if( this.TableAlias == null && rhs.TableAlias == null ) { return true; } ! else if( this.TableAlias == null && rhs.TableAlias != null ) { return false; } ! else { ! return this.TableAlias.Equals( rhs.TableAlias ); } } + /// <summary> + /// + /// </summary> + /// <returns></returns> public override int GetHashCode() { int hashCode = 0; ! unchecked { ! if( _sqlType != null ) { hashCode += _sqlType.GetHashCode(); } ! if( name != null ) { hashCode += name.GetHashCode(); } ! if( tableAlias != null ) { hashCode += tableAlias.GetHashCode(); *************** *** 154,162 **** } ! public override string ToString() { ! return (tableAlias==null || tableAlias.Length == 0)? ! ":" + name : ! ":" + tableAlias + "." + name; } --- 172,179 ---- } ! /// <summary></summary> ! public override string ToString() { ! return ( tableAlias == null || tableAlias.Length == 0 ) ? ":" + name : ":" + tableAlias + "." + name; } *************** *** 165,177 **** #region ICloneable Members ! public Parameter Clone() { ! ! Parameter paramClone = (Parameter)this.MemberwiseClone(); return paramClone; } ! object ICloneable.Clone() { return Clone(); --- 182,201 ---- #region ICloneable Members ! /// <summary> ! /// ! /// </summary> ! /// <returns></returns> ! public Parameter Clone() { ! Parameter paramClone = ( Parameter ) this.MemberwiseClone(); return paramClone; } ! /// <summary> ! /// ! /// </summary> ! /// <returns></returns> ! object ICloneable.Clone() { return Clone(); *************** *** 179,185 **** #endregion - - } ! } --- 203,207 ---- #endregion } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:24:58
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9130 Modified Files: ConditionalFragment.cs DecodeCaseFragment.cs ForUpdateFragment.cs InFragment.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: ConditionalFragment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/ConditionalFragment.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ConditionalFragment.cs 4 Mar 2004 04:10:15 -0000 1.1 --- ConditionalFragment.cs 31 Dec 2004 22:24:48 -0000 1.2 *************** *** 1,14 **** - using System; using System.Text; using NHibernate.Util; ! namespace NHibernate.SqlCommand { ! ! public class ConditionalFragment { private string tableAlias; ! private string[] lhs; ! private string[] rhs; private string op = "="; --- 1,13 ---- using System.Text; using NHibernate.Util; ! namespace NHibernate.SqlCommand { ! /// <summary></summary> ! public class ConditionalFragment { private string tableAlias; ! private string[ ] lhs; ! private string[ ] rhs; private string op = "="; *************** *** 17,21 **** /// </summary> /// <param name="op">The op to set</param> ! public ConditionalFragment SetOp(string op) { this.op = op; --- 16,20 ---- /// </summary> /// <param name="op">The op to set</param> ! public ConditionalFragment SetOp( string op ) { this.op = op; *************** *** 23,27 **** } ! public ConditionalFragment SetTableAlias(string tableAlias) { this.tableAlias = tableAlias; --- 22,31 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableAlias"></param> ! /// <returns></returns> ! public ConditionalFragment SetTableAlias( string tableAlias ) { this.tableAlias = tableAlias; *************** *** 29,33 **** } ! public ConditionalFragment SetCondition(string[] lhs, string[] rhs) { this.lhs = lhs; --- 33,43 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="lhs"></param> ! /// <param name="rhs"></param> ! /// <returns></returns> ! public ConditionalFragment SetCondition( string[ ] lhs, string[ ] rhs ) { this.lhs = lhs; *************** *** 36,62 **** } ! public ConditionalFragment SetCondition(string[] lhs, string rhs) { this.lhs = lhs; ! this.rhs = ArrayHelper.FillArray(rhs, lhs.Length); return this; } ! public SqlString ToSqlStringFragment() { ! StringBuilder buf = new StringBuilder( lhs.Length * 10 ); ! for ( int i=0; i<lhs.Length; i++ ) { ! buf.Append(tableAlias) ! .Append(StringHelper.Dot) ! .Append( lhs[i] ) ! .Append(op) ! .Append( rhs[i] ); ! if (i<lhs.Length-1) buf.Append(" and "); } ! return new SqlString(buf.ToString()); } } ! } ! ! --- 46,80 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="lhs"></param> ! /// <param name="rhs"></param> ! /// <returns></returns> ! public ConditionalFragment SetCondition( string[ ] lhs, string rhs ) { this.lhs = lhs; ! this.rhs = ArrayHelper.FillArray( rhs, lhs.Length ); return this; } ! /// <summary></summary> ! public SqlString ToSqlStringFragment() { ! StringBuilder buf = new StringBuilder( lhs.Length*10 ); ! for( int i = 0; i < lhs.Length; i++ ) { ! buf.Append( tableAlias ) ! .Append( StringHelper.Dot ) ! .Append( lhs[ i ] ) ! .Append( op ) ! .Append( rhs[ i ] ); ! if( i < lhs.Length - 1 ) ! { ! buf.Append( " and " ); ! } } ! return new SqlString( buf.ToString() ); } } ! } \ No newline at end of file Index: ForUpdateFragment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/ForUpdateFragment.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ForUpdateFragment.cs 20 Aug 2004 17:39:02 -0000 1.5 --- ForUpdateFragment.cs 31 Dec 2004 22:24:48 -0000 1.6 *************** *** 1,46 **** using System; - using System.Collections; using System.Text; - using NHibernate.Util; ! namespace NHibernate.SqlCommand { - /// <summary> /// Represents an SQL <c>for update of ... nowait</c> statement /// </summary> ! public class ForUpdateFragment { - private StringBuilder aliases = new StringBuilder(); private bool nowait; ! public ForUpdateFragment() { } ! public bool NoWait { ! get { return nowait;} ! set { nowait = value;} } ! public ForUpdateFragment AddTableAlias(string alias) { ! if(aliases.Length > 0 ) aliases.Append(StringHelper.CommaSpace); ! aliases.Append(alias); return this; } ! public SqlString ToSqlStringFragment() { ! return aliases.Length==0 ? ! new SqlString(String.Empty) : ! new SqlString(" for update of " + aliases + ( nowait ? " nowait" : String.Empty)); } } ! } ! ! --- 1,51 ---- using System; using System.Text; using NHibernate.Util; ! namespace NHibernate.SqlCommand { /// <summary> /// Represents an SQL <c>for update of ... nowait</c> statement /// </summary> ! public class ForUpdateFragment { private StringBuilder aliases = new StringBuilder(); private bool nowait; ! /// <summary></summary> ! public ForUpdateFragment() { } ! /// <summary></summary> ! public bool NoWait { ! get { return nowait; } ! set { nowait = value; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <returns></returns> ! public ForUpdateFragment AddTableAlias( string alias ) { ! if( aliases.Length > 0 ) ! { ! aliases.Append( StringHelper.CommaSpace ); ! } ! aliases.Append( alias ); return this; } ! /// <summary></summary> ! public SqlString ToSqlStringFragment() { ! return aliases.Length == 0 ? ! new SqlString( String.Empty ) : ! new SqlString( " for update of " + aliases + ( nowait ? " nowait" : String.Empty ) ); } } ! } \ No newline at end of file Index: InFragment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/InFragment.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** InFragment.cs 16 Dec 2004 21:51:08 -0000 1.2 --- InFragment.cs 31 Dec 2004 22:24:48 -0000 1.3 *************** *** 1,5 **** - using System; using System.Collections; - using NHibernate.Util; --- 1,3 ---- *************** *** 13,25 **** private string columnName; private ArrayList values = new ArrayList(); ! ! public InFragment AddValue(string value) { ! values.Add(value); return this; } ! public InFragment SetColumn(string columnName) { this.columnName = columnName; --- 11,33 ---- private string columnName; private ArrayList values = new ArrayList(); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <returns></returns> ! public InFragment AddValue( string value ) { ! values.Add( value ); return this; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="columnName"></param> ! /// <returns></returns> ! public InFragment SetColumn( string columnName ) { this.columnName = columnName; *************** *** 27,31 **** } ! public InFragment SetColumn(string alias, string columnName) { this.columnName = alias + StringHelper.Dot + columnName; --- 35,45 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="columnName"></param> ! /// <returns></returns> ! public InFragment SetColumn( string alias, string columnName ) { this.columnName = alias + StringHelper.Dot + columnName; *************** *** 33,42 **** } ! public SqlString ToFragmentString() { ! SqlStringBuilder buf = new SqlStringBuilder( values.Count * 5 ); buf.Add( columnName ); ! ! if( values.Count > 1 ) { // is a comma needed before the value that's about to be added - it --- 47,57 ---- } ! /// <summary></summary> ! public SqlString ToFragmentString() { ! SqlStringBuilder buf = new SqlStringBuilder( values.Count*5 ); buf.Add( columnName ); ! ! if( values.Count > 1 ) { // is a comma needed before the value that's about to be added - it *************** *** 49,59 **** buf.Add( " in (" ); ! for( int i=0; i<values.Count; i++ ) { ! if("null".Equals(values[i])) { allowNull = true; } ! else { if( commaNeeded ) --- 64,74 ---- buf.Add( " in (" ); ! for( int i = 0; i < values.Count; i++ ) { ! if( "null".Equals( values[ i ] ) ) { allowNull = true; } ! else { if( commaNeeded ) *************** *** 61,66 **** buf.Add( StringHelper.CommaSpace ); } ! buf.Add( (string)values[i] ); ! // a value has been added into the IN clause so the next // one needs a comma before it --- 76,81 ---- buf.Add( StringHelper.CommaSpace ); } ! buf.Add( ( string ) values[ i ] ); ! // a value has been added into the IN clause so the next // one needs a comma before it *************** *** 69,98 **** } ! buf.Add(StringHelper.ClosedParen); ! // if "null" is in the list of values then add to the beginning of the // SqlString "is null or [column] (" + [rest of sqlstring here] + ")" ! if( allowNull ) { ! buf.Insert(0, " is null or ") ! .Insert(0, columnName) ! .Insert(0, StringHelper.OpenParen) ! .Add(StringHelper.ClosedParen); } ! } ! else { ! string value = values[0] as string; ! if ( "null".Equals(value) ) { ! buf.Add(" is null"); ! } ! else { ! buf.Add( "=" + values[0] ); } } return buf.ToSqlString(); ! } } ! } --- 84,113 ---- } ! buf.Add( StringHelper.ClosedParen ); ! // if "null" is in the list of values then add to the beginning of the // SqlString "is null or [column] (" + [rest of sqlstring here] + ")" ! if( allowNull ) { ! buf.Insert( 0, " is null or " ) ! .Insert( 0, columnName ) ! .Insert( 0, StringHelper.OpenParen ) ! .Add( StringHelper.ClosedParen ); } ! } ! else { ! string value = values[ 0 ] as string; ! if( "null".Equals( value ) ) { ! buf.Add( " is null" ); ! } ! else { ! buf.Add( "=" + values[ 0 ] ); } } return buf.ToSqlString(); ! } } ! } \ No newline at end of file Index: DecodeCaseFragment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/DecodeCaseFragment.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DecodeCaseFragment.cs 16 Aug 2004 05:18:52 -0000 1.3 --- DecodeCaseFragment.cs 31 Dec 2004 22:24:48 -0000 1.4 *************** *** 1,6 **** - using System; using System.Collections; using System.Text; - using NHibernate.Util; --- 1,4 ---- *************** *** 10,18 **** /// Represents an SQL decode(pkvalue, key1, 1, key2, 2, ..., 0) /// </summary> ! public class DecodeCaseFragment : CaseFragment { private Dialect.Dialect dialect; ! public DecodeCaseFragment(Dialect.Dialect dialect) { this.dialect = dialect; --- 8,20 ---- /// Represents an SQL decode(pkvalue, key1, 1, key2, 2, ..., 0) /// </summary> ! public class DecodeCaseFragment : CaseFragment { private Dialect.Dialect dialect; ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! public DecodeCaseFragment( Dialect.Dialect dialect ) { this.dialect = dialect; *************** *** 22,26 **** private IList cases = new ArrayList(); ! public override CaseFragment SetReturnColumnName(string returnColumnName) { this.returnColumnName = returnColumnName; --- 24,33 ---- private IList cases = new ArrayList(); ! /// <summary> ! /// ! /// </summary> ! /// <param name="returnColumnName"></param> ! /// <returns></returns> ! public override CaseFragment SetReturnColumnName( string returnColumnName ) { this.returnColumnName = returnColumnName; *************** *** 28,74 **** } ! public override CaseFragment SetReturnColumnName(string returnColumnName, string suffix) { ! return SetReturnColumnName( new Alias(suffix).ToAliasString(returnColumnName, dialect) ); } ! public override CaseFragment AddWhenColumnNotNull(string alias, string columnName, string columnValue) { string key = alias + StringHelper.Dot + columnName; ! if(columnValue.Equals("0")) { ! cases.Insert(0, key); } ! else { ! cases.Add(", " + key + ", " + columnValue); } ! return this; } ! public override SqlString ToSqlStringFragment() { ! ! StringBuilder buf = new StringBuilder( cases.Count * 15 + 10 ); ! buf.Append("decode ("); ! for(int i = 0; i < cases.Count; i++) { ! buf.Append(cases[i]); } ! buf.Append(",0 )"); ! if(returnColumnName!=null) { ! buf.Append(" as ") ! .Append(returnColumnName); } ! return new SqlString(buf.ToString()); } } ! } --- 35,94 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="returnColumnName"></param> ! /// <param name="suffix"></param> ! /// <returns></returns> ! public override CaseFragment SetReturnColumnName( string returnColumnName, string suffix ) { ! return SetReturnColumnName( new Alias( suffix ).ToAliasString( returnColumnName, dialect ) ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="columnName"></param> ! /// <param name="columnValue"></param> ! /// <returns></returns> ! public override CaseFragment AddWhenColumnNotNull( string alias, string columnName, string columnValue ) { string key = alias + StringHelper.Dot + columnName; ! if( columnValue.Equals( "0" ) ) { ! cases.Insert( 0, key ); } ! else { ! cases.Add( ", " + key + ", " + columnValue ); } ! return this; } ! /// <summary></summary> ! public override SqlString ToSqlStringFragment() { ! StringBuilder buf = new StringBuilder( cases.Count*15 + 10 ); ! buf.Append( "decode (" ); ! for( int i = 0; i < cases.Count; i++ ) { ! buf.Append( cases[ i ] ); } ! buf.Append( ",0 )" ); ! if( returnColumnName != null ) { ! buf.Append( " as " ) ! .Append( returnColumnName ); } ! return new SqlString( buf.ToString() ); } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:24:47
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9087 Modified Files: Alias.cs ANSICaseFragment.cs ANSIJoinFragment.cs CaseFragment.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: ANSIJoinFragment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/ANSIJoinFragment.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ANSIJoinFragment.cs 18 Aug 2004 20:43:58 -0000 1.2 --- ANSIJoinFragment.cs 31 Dec 2004 22:24:36 -0000 1.3 *************** *** 1,4 **** using System; - using NHibernate.Engine; using NHibernate.Type; --- 1,3 ---- *************** *** 15,22 **** private SqlStringBuilder conditions = new SqlStringBuilder(); ! public override void AddJoin(string tableName, string alias, string[] fkColumns, string[] pkColumns, JoinType joinType) { string joinString = null; ! switch (joinType) { case JoinType.InnerJoin: --- 14,29 ---- private SqlStringBuilder conditions = new SqlStringBuilder(); ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <param name="alias"></param> ! /// <param name="fkColumns"></param> ! /// <param name="pkColumns"></param> ! /// <param name="joinType"></param> ! public override void AddJoin( string tableName, string alias, string[ ] fkColumns, string[ ] pkColumns, JoinType joinType ) { string joinString = null; ! switch( joinType ) { case JoinType.InnerJoin: *************** *** 33,66 **** break; default: ! throw new AssertionFailure("undefind join type"); } buffer.Add( joinString + tableName + ' ' + alias + " on " ); ! for (int j=0; j<fkColumns.Length; j++) { ! if (fkColumns[j].IndexOf('.')<1) throw new AssertionFailure("missing alias"); ! buffer.Add( fkColumns[j] + "=" + alias + StringHelper.Dot + pkColumns[j] ); ! if (j<fkColumns.Length-1) buffer.Add(" and "); } } ! public override SqlString ToFromFragmentString { get { return buffer.ToSqlString(); } } ! public override SqlString ToWhereFragmentString { get { return conditions.ToSqlString(); } } ! public override void AddJoins(SqlString fromFragment, SqlString whereFragment) { ! buffer.Add(fromFragment); //where fragment must be empty! } ! public override JoinFragment Copy() { ANSIJoinFragment copy = new ANSIJoinFragment(); --- 40,87 ---- break; default: ! throw new AssertionFailure( "undefind join type" ); } buffer.Add( joinString + tableName + ' ' + alias + " on " ); ! for( int j = 0; j < fkColumns.Length; j++ ) { ! if( fkColumns[ j ].IndexOf( '.' ) < 1 ) ! { ! throw new AssertionFailure( "missing alias" ); ! } ! buffer.Add( fkColumns[ j ] + "=" + alias + StringHelper.Dot + pkColumns[ j ] ); ! if( j < fkColumns.Length - 1 ) ! { ! buffer.Add( " and " ); ! } } } ! /// <summary></summary> ! public override SqlString ToFromFragmentString { get { return buffer.ToSqlString(); } } ! /// <summary></summary> ! public override SqlString ToWhereFragmentString { get { return conditions.ToSqlString(); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="fromFragment"></param> ! /// <param name="whereFragment"></param> ! public override void AddJoins( SqlString fromFragment, SqlString whereFragment ) { ! buffer.Add( fromFragment ); //where fragment must be empty! } ! /// <summary></summary> ! public override JoinFragment Copy() { ANSIJoinFragment copy = new ANSIJoinFragment(); *************** *** 69,107 **** } ! public override void AddCondition(string alias, string[] columns, string condition) { ! for (int i=0; i<columns.Length; i++) { ! conditions.Add( " and " + alias + StringHelper.Dot + columns[i] + condition ); } } ! public override void AddCondition(string alias, string[] columns, string condition, IType conditionType, ISessionFactoryImplementor factory) { ! Parameter[] parameters = Parameter.GenerateParameters(factory, alias, columns, conditionType); ! for( int i=0; i<columns.Length; i++) { ! conditions.Add( " and " + alias + StringHelper.Dot + columns[i] + condition ); ! conditions.Add( parameters[i] ); } } ! ! public override void AddCrossJoin(string tableName, string alias) { ! buffer.Add( StringHelper.CommaSpace + tableName + " " + alias); } ! public override void AddCondition(string alias, string[] fkColumns, string[] pkColumns) { throw new NotSupportedException(); } ! public override void AddCondition(string condition) { throw new NotSupportedException(); } ! public override void AddCondition(SqlString condition) { throw new NotSupportedException(); --- 90,160 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="columns"></param> ! /// <param name="condition"></param> ! public override void AddCondition( string alias, string[ ] columns, string condition ) { ! for( int i = 0; i < columns.Length; i++ ) { ! conditions.Add( " and " + alias + StringHelper.Dot + columns[ i ] + condition ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="columns"></param> ! /// <param name="condition"></param> ! /// <param name="conditionType"></param> ! /// <param name="factory"></param> ! public override void AddCondition( string alias, string[ ] columns, string condition, IType conditionType, ISessionFactoryImplementor factory ) { ! Parameter[ ] parameters = Parameter.GenerateParameters( factory, alias, columns, conditionType ); ! for( int i = 0; i < columns.Length; i++ ) { ! conditions.Add( " and " + alias + StringHelper.Dot + columns[ i ] + condition ); ! conditions.Add( parameters[ i ] ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <param name="alias"></param> ! public override void AddCrossJoin( string tableName, string alias ) { ! buffer.Add( StringHelper.CommaSpace + tableName + " " + alias ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="fkColumns"></param> ! /// <param name="pkColumns"></param> ! public override void AddCondition( string alias, string[ ] fkColumns, string[ ] pkColumns ) { throw new NotSupportedException(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="condition"></param> ! public override void AddCondition( string condition ) { throw new NotSupportedException(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="condition"></param> ! public override void AddCondition( SqlString condition ) { throw new NotSupportedException(); *************** *** 110,112 **** } ! } --- 163,165 ---- } ! } \ No newline at end of file Index: Alias.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/Alias.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Alias.cs 16 Aug 2004 05:18:52 -0000 1.1 --- Alias.cs 31 Dec 2004 22:24:36 -0000 1.2 *************** *** 1,6 **** - using System; - - using NHibernate.Dialect; - namespace NHibernate.SqlCommand { --- 1,2 ---- *************** *** 13,23 **** private readonly string suffix; ! public Alias(int length, string suffix) { ! this.length = (suffix==null) ? length : length - suffix.Length; this.suffix = suffix; } ! public Alias(string suffix) { this.length = int.MaxValue; --- 9,28 ---- private readonly string suffix; ! /// <summary> ! /// ! /// </summary> ! /// <param name="length"></param> ! /// <param name="suffix"></param> ! public Alias( int length, string suffix ) { ! this.length = ( suffix == null ) ? length : length - suffix.Length; this.suffix = suffix; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="suffix"></param> ! public Alias( string suffix ) { this.length = int.MaxValue; *************** *** 25,54 **** } ! public string ToAliasString(string sqlIdentifier, Dialect.Dialect dialect) { ! bool isQuoted = dialect.IsQuoted(sqlIdentifier); string unquoted; ! if(isQuoted) { ! unquoted = dialect.UnQuote(sqlIdentifier); } ! else { unquoted = sqlIdentifier; } ! if ( unquoted.Length > length ) { ! unquoted = unquoted.Substring(0, length); } ! if (suffix!=null) unquoted += suffix; ! if ( isQuoted ) { ! return dialect.QuoteForAliasName(unquoted); } ! else { return unquoted; --- 30,68 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlIdentifier"></param> ! /// <param name="dialect"></param> ! /// <returns></returns> ! public string ToAliasString( string sqlIdentifier, Dialect.Dialect dialect ) { ! bool isQuoted = dialect.IsQuoted( sqlIdentifier ); string unquoted; ! if( isQuoted ) { ! unquoted = dialect.UnQuote( sqlIdentifier ); } ! else { unquoted = sqlIdentifier; } ! if( unquoted.Length > length ) { ! unquoted = unquoted.Substring( 0, length ); } ! if( suffix != null ) ! { ! unquoted += suffix; ! } ! if( isQuoted ) { ! return dialect.QuoteForAliasName( unquoted ); } ! else { return unquoted; *************** *** 57,80 **** } ! public string ToUnquotedAliasString(string sqlIdentifier, Dialect.Dialect dialect) { ! string unquoted = dialect.UnQuote(sqlIdentifier); ! if(unquoted.Length > length) { ! unquoted = unquoted.Substring(0, length); } ! if(suffix!=null) unquoted += suffix; return unquoted; } ! public string[] ToUnquotedAliasStrings(string[] sqlIdentifiers, Dialect.Dialect dialect) { ! string[] aliases = new string[sqlIdentifiers.Length]; ! for(int i = 0; i < sqlIdentifiers.Length; i++) { ! aliases[i] = ToUnquotedAliasString(sqlIdentifiers[i], dialect); } --- 71,109 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlIdentifier"></param> ! /// <param name="dialect"></param> ! /// <returns></returns> ! public string ToUnquotedAliasString( string sqlIdentifier, Dialect.Dialect dialect ) { ! string unquoted = dialect.UnQuote( sqlIdentifier ); ! if( unquoted.Length > length ) { ! unquoted = unquoted.Substring( 0, length ); } ! if( suffix != null ) ! { ! unquoted += suffix; ! } return unquoted; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlIdentifiers"></param> ! /// <param name="dialect"></param> ! /// <returns></returns> ! public string[ ] ToUnquotedAliasStrings( string[ ] sqlIdentifiers, Dialect.Dialect dialect ) { ! string[ ] aliases = new string[sqlIdentifiers.Length]; ! for( int i = 0; i < sqlIdentifiers.Length; i++ ) { ! aliases[ i ] = ToUnquotedAliasString( sqlIdentifiers[ i ], dialect ); } *************** *** 82,96 **** } ! ! public string[] ToAliasStrings(string[] sqlIdentifiers, Dialect.Dialect dialect) { ! string[] aliases = new string[ sqlIdentifiers.Length ]; ! for ( int i=0; i<sqlIdentifiers.Length; i++ ) { ! aliases[i] = ToAliasString(sqlIdentifiers[i], dialect); } return aliases; } } ! } --- 111,131 ---- } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlIdentifiers"></param> ! /// <param name="dialect"></param> ! /// <returns></returns> ! public string[ ] ToAliasStrings( string[ ] sqlIdentifiers, Dialect.Dialect dialect ) { ! string[ ] aliases = new string[sqlIdentifiers.Length]; ! for( int i = 0; i < sqlIdentifiers.Length; i++ ) { ! aliases[ i ] = ToAliasString( sqlIdentifiers[ i ], dialect ); } return aliases; } } ! } \ No newline at end of file Index: CaseFragment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/CaseFragment.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CaseFragment.cs 4 Mar 2004 04:10:15 -0000 1.1 --- CaseFragment.cs 31 Dec 2004 22:24:36 -0000 1.2 *************** *** 1,4 **** - using System; - namespace NHibernate.SqlCommand { --- 1,2 ---- *************** *** 6,17 **** /// Represents an SQL <c>case when ... then ... end as ...</c> /// </summary> ! public abstract class CaseFragment { ! public abstract CaseFragment SetReturnColumnName(string returnColumnName); ! public abstract CaseFragment SetReturnColumnName(string returnColumnName, string suffix); ! public abstract CaseFragment AddWhenColumnNotNull(string alias, string columnName, string columnValue); public abstract SqlString ToSqlStringFragment(); } ! ! } --- 4,37 ---- /// Represents an SQL <c>case when ... then ... end as ...</c> /// </summary> ! public abstract class CaseFragment { ! /// <summary> ! /// ! /// </summary> ! /// <param name="returnColumnName"></param> ! /// <returns></returns> ! public abstract CaseFragment SetReturnColumnName( string returnColumnName ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="returnColumnName"></param> ! /// <param name="suffix"></param> ! /// <returns></returns> ! public abstract CaseFragment SetReturnColumnName( string returnColumnName, string suffix ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="columnName"></param> ! /// <param name="columnValue"></param> ! /// <returns></returns> ! public abstract CaseFragment AddWhenColumnNotNull( string alias, string columnName, string columnValue ); ! ! /// <summary></summary> public abstract SqlString ToSqlStringFragment(); } ! ! } \ No newline at end of file Index: ANSICaseFragment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/ANSICaseFragment.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ANSICaseFragment.cs 16 Aug 2004 05:18:52 -0000 1.3 --- ANSICaseFragment.cs 31 Dec 2004 22:24:36 -0000 1.4 *************** *** 1,9 **** - using System; using System.Collections; using System.Text; - using NHibernate.Util; - namespace NHibernate.SqlCommand { --- 1,6 ---- *************** *** 16,20 **** private Dialect.Dialect dialect; ! public ANSICaseFragment(Dialect.Dialect dialect) { this.dialect = dialect; --- 13,21 ---- private Dialect.Dialect dialect; ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! public ANSICaseFragment( Dialect.Dialect dialect ) { this.dialect = dialect; *************** *** 25,29 **** private IList cases = new ArrayList(); ! public override CaseFragment SetReturnColumnName(string returnColumnName) { this.returnColumnName = returnColumnName; --- 26,35 ---- private IList cases = new ArrayList(); ! /// <summary> ! /// ! /// </summary> ! /// <param name="returnColumnName"></param> ! /// <returns></returns> ! public override CaseFragment SetReturnColumnName( string returnColumnName ) { this.returnColumnName = returnColumnName; *************** *** 31,69 **** } ! public override CaseFragment SetReturnColumnName(string returnColumnName, string suffix) { ! return SetReturnColumnName( new Alias(suffix).ToAliasString( returnColumnName, dialect ) ); } ! public override CaseFragment AddWhenColumnNotNull(string alias, string columnName, string columnValue) { string key = alias + StringHelper.Dot + columnName + " is not null"; ! ! cases.Add(" when " + key + " then " + columnValue ); return this; } public override SqlString ToSqlStringFragment() { ! ! StringBuilder buf = new StringBuilder( cases.Count * 15 + 10 ); ! buf.Append("case"); ! for(int i = 0 ; i < cases.Count; i++) { ! buf.Append(cases[i]); } ! buf.Append(" end"); ! if( returnColumnName != null ) { ! buf.Append(" as ") ! .Append(returnColumnName); } ! return new SqlString(buf.ToString()); } } ! } --- 37,88 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="returnColumnName"></param> ! /// <param name="suffix"></param> ! /// <returns></returns> ! public override CaseFragment SetReturnColumnName( string returnColumnName, string suffix ) { ! return SetReturnColumnName( new Alias( suffix ).ToAliasString( returnColumnName, dialect ) ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="alias"></param> ! /// <param name="columnName"></param> ! /// <param name="columnValue"></param> ! /// <returns></returns> ! public override CaseFragment AddWhenColumnNotNull( string alias, string columnName, string columnValue ) { string key = alias + StringHelper.Dot + columnName + " is not null"; ! ! cases.Add( " when " + key + " then " + columnValue ); return this; } + /// <summary></summary> public override SqlString ToSqlStringFragment() { ! StringBuilder buf = new StringBuilder( cases.Count*15 + 10 ); ! buf.Append( "case" ); ! for( int i = 0; i < cases.Count; i++ ) { ! buf.Append( cases[ i ] ); } ! buf.Append( " end" ); ! if( returnColumnName != null ) { ! buf.Append( " as " ) ! .Append( returnColumnName ); } ! return new SqlString( buf.ToString() ); } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:08:47
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6703 Modified Files: NHibernateProxyHelper.cs ProxyGeneratorFactory.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: NHibernateProxyHelper.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/NHibernateProxyHelper.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NHibernateProxyHelper.cs 16 Dec 2004 21:51:48 -0000 1.3 --- NHibernateProxyHelper.cs 31 Dec 2004 22:08:37 -0000 1.4 *************** *** 1,4 **** - using System; - namespace NHibernate.Proxy { --- 1,2 ---- *************** *** 10,14 **** public sealed class NHibernateProxyHelper { ! private NHibernateProxyHelper() { //can't instantiate --- 8,12 ---- public sealed class NHibernateProxyHelper { ! private NHibernateProxyHelper() { //can't instantiate *************** *** 23,31 **** /// of the Proxied object. /// </returns> ! public static LazyInitializer GetLazyInitializer(INHibernateProxy proxy) { LazyInitializer li = ProxyGeneratorFactory.GetProxyGenerator().GetLazyInitializer( proxy ); return li; ! } --- 21,29 ---- /// of the Proxied object. /// </returns> ! public static LazyInitializer GetLazyInitializer( INHibernateProxy proxy ) { LazyInitializer li = ProxyGeneratorFactory.GetProxyGenerator().GetLazyInitializer( proxy ); return li; ! } *************** *** 36,48 **** /// <param name="obj">The object to get the type of.</param> /// <returns>The Underlying Type for the object regardless of if it is a Proxy.</returns> ! public static System.Type GetClass(object obj) { ! if (obj is INHibernateProxy) { ! INHibernateProxy proxy = (INHibernateProxy) obj; LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer( proxy ); return li.PersistentClass; } ! else { return obj.GetType(); --- 34,46 ---- /// <param name="obj">The object to get the type of.</param> /// <returns>The Underlying Type for the object regardless of if it is a Proxy.</returns> ! public static System.Type GetClass( object obj ) { ! if( obj is INHibernateProxy ) { ! INHibernateProxy proxy = ( INHibernateProxy ) obj; LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer( proxy ); return li.PersistentClass; } ! else { return obj.GetType(); *************** *** 50,52 **** } } ! } --- 48,50 ---- } } ! } \ No newline at end of file Index: ProxyGeneratorFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/ProxyGeneratorFactory.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ProxyGeneratorFactory.cs 16 Dec 2004 21:51:48 -0000 1.3 --- ProxyGeneratorFactory.cs 31 Dec 2004 22:08:37 -0000 1.4 *************** *** 1,3 **** ! using System; namespace NHibernate.Proxy --- 1,3 ---- ! using log4net; namespace NHibernate.Proxy *************** *** 8,16 **** public sealed class ProxyGeneratorFactory { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(ProxyGeneratorFactory) ); private static IProxyGenerator _generator = new CastleProxyGenerator(); ! ! public static IProxyGenerator GetProxyGenerator() { //TODO: make this read from a configuration file!!! At this point anybody --- 8,17 ---- public sealed class ProxyGeneratorFactory { ! private static readonly ILog log = LogManager.GetLogger( typeof( ProxyGeneratorFactory ) ); private static IProxyGenerator _generator = new CastleProxyGenerator(); ! ! /// <summary></summary> ! public static IProxyGenerator GetProxyGenerator() { //TODO: make this read from a configuration file!!! At this point anybody *************** *** 19,21 **** } } ! } --- 20,22 ---- } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:08:36
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6679 Modified Files: INHibernateProxy.cs IProxyGenerator.cs LazyInitializer.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: LazyInitializer.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/LazyInitializer.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LazyInitializer.cs 16 Dec 2004 21:51:48 -0000 1.4 --- LazyInitializer.cs 31 Dec 2004 22:08:25 -0000 1.5 *************** *** 1,7 **** using System; - using System.Collections; using System.Reflection; using System.Runtime.Serialization; ! using NHibernate.Engine; using NHibernate.Util; --- 1,6 ---- using System; using System.Reflection; using System.Runtime.Serialization; ! using log4net; using NHibernate.Engine; using NHibernate.Util; *************** *** 29,38 **** private object _target = null; private object _id; [NonSerialized] private ISessionImplementor _session; private System.Type _persistentClass; private PropertyInfo _identifierPropertyInfo; private bool _overridesEquals; ! /// <summary> /// Create a LazyInitializer to handle all of the Methods/Properties that are called --- 28,39 ---- private object _target = null; private object _id; + [NonSerialized] private ISessionImplementor _session; + private System.Type _persistentClass; private PropertyInfo _identifierPropertyInfo; private bool _overridesEquals; ! /// <summary> /// Create a LazyInitializer to handle all of the Methods/Properties that are called *************** *** 43,47 **** /// <param name="identifierPropertyInfo">The PropertyInfo for the <id> property.</param> /// <param name="session">The ISession this Proxy is in.</param> ! protected LazyInitializer(System.Type persistentClass, object id, PropertyInfo identifierPropertyInfo, ISessionImplementor session) { _persistentClass = persistentClass; --- 44,48 ---- /// <param name="identifierPropertyInfo">The PropertyInfo for the <id> property.</param> /// <param name="session">The ISession this Proxy is in.</param> ! protected LazyInitializer( System.Type persistentClass, object id, PropertyInfo identifierPropertyInfo, ISessionImplementor session ) { _persistentClass = persistentClass; *************** *** 49,53 **** _session = session; _identifierPropertyInfo = identifierPropertyInfo; ! _overridesEquals = ReflectHelper.OverridesEquals(_persistentClass); } --- 50,54 ---- _session = session; _identifierPropertyInfo = identifierPropertyInfo; ! _overridesEquals = ReflectHelper.OverridesEquals( _persistentClass ); } *************** *** 58,74 **** /// Thrown when the Proxy has no Session or the Session is not open. /// </exception> ! public void Initialize() { ! if( _target==null ) { ! if( _session==null ) { throw new HibernateException( "Could not initialize proxy - no Session." ); } ! else if( _session.IsOpen==false ) { throw new HibernateException( "Could not initialize proxy - the owning Session was closed." ); } ! else { _target = _session.ImmediateLoad( _persistentClass, _id ); --- 59,75 ---- /// Thrown when the Proxy has no Session or the Session is not open. /// </exception> ! public void Initialize() { ! if( _target == null ) { ! if( _session == null ) { throw new HibernateException( "Could not initialize proxy - no Session." ); } ! else if( _session.IsOpen == false ) { throw new HibernateException( "Could not initialize proxy - the owning Session was closed." ); } ! else { _target = _session.ImmediateLoad( _persistentClass, _id ); *************** *** 87,100 **** /// Thrown whenever a problem is encountered during the Initialization of the Proxy. /// </exception> ! private void InitializeWrapExceptions() { ! try { Initialize(); } ! catch( Exception e ) { ! log4net.LogManager.GetLogger(typeof(LazyInitializer)).Error("Exception initializing proxy.", e); ! throw new LazyInitializationException(e); } } --- 88,101 ---- /// Thrown whenever a problem is encountered during the Initialization of the Proxy. /// </exception> ! private void InitializeWrapExceptions() { ! try { Initialize(); } ! catch( Exception e ) { ! LogManager.GetLogger( typeof( LazyInitializer ) ).Error( "Exception initializing proxy.", e ); ! throw new LazyInitializationException( e ); } } *************** *** 110,145 **** /// itself or delegates calls to the method GetObjectData to the LazyInitializer. /// </remarks> ! protected virtual void AddSerializationInfo(SerializationInfo info) { } ! public object Identifier { get { return _id; } } ! public System.Type PersistentClass { get { return _persistentClass; } } ! public bool IsUninitialized { ! get { return (_target==null); } } ! public ISessionImplementor Session { get { return _session; } ! set { ! if(value!=_session) { ! if( _session!=null && _session.IsOpen ) { //TODO: perhaps this should be some other RuntimeException... ! throw new LazyInitializationException("Illegally attempted to associate a proxy with two open Sessions"); } ! else { _session = value; --- 111,150 ---- /// itself or delegates calls to the method GetObjectData to the LazyInitializer. /// </remarks> ! protected virtual void AddSerializationInfo( SerializationInfo info ) { } ! /// <summary></summary> ! public object Identifier { get { return _id; } } ! /// <summary></summary> ! public System.Type PersistentClass { get { return _persistentClass; } } ! /// <summary></summary> ! public bool IsUninitialized { ! get { return ( _target == null ); } } ! /// <summary></summary> ! public ISessionImplementor Session { get { return _session; } ! set { ! if( value != _session ) { ! if( _session != null && _session.IsOpen ) { //TODO: perhaps this should be some other RuntimeException... ! throw new LazyInitializationException( "Illegally attempted to associate a proxy with two open Sessions" ); } ! else { _session = value; *************** *** 153,157 **** /// </summary> /// <returns>The Persistent Object this proxy is Proxying.</returns> ! public object GetImplementation() { InitializeWrapExceptions(); --- 158,162 ---- /// </summary> /// <returns>The Persistent Object this proxy is Proxying.</returns> ! public object GetImplementation() { InitializeWrapExceptions(); *************** *** 164,171 **** /// <param name="s">The Session to get the object from.</param> /// <returns>The Persistent Object this proxy is Proxying, or <c>null</c>.</returns> ! public object GetImplementation(ISessionImplementor s) { ! Key key = new Key( Identifier, s.Factory.GetPersister(PersistentClass) ); ! return s.GetEntity(key); } --- 169,176 ---- /// <param name="s">The Session to get the object from.</param> /// <returns>The Persistent Object this proxy is Proxying, or <c>null</c>.</returns> ! public object GetImplementation( ISessionImplementor s ) { ! Key key = new Key( Identifier, s.Factory.GetPersister( PersistentClass ) ); ! return s.GetEntity( key ); } *************** *** 181,197 **** /// which indicates that the Proxy will need to forward to the real implementation. /// </returns> ! public virtual object Invoke(MethodBase method, params object[] args) { // if the Proxy Engine delegates the call of GetObjectData to the Initializer // then we need to handle it. Castle.DynamicProxy takes care of serializing // proxies for us, but other providers might not. ! if( method.Name.Equals("GetObjectData") ) { ! SerializationInfo info = (SerializationInfo)args[0]; ! StreamingContext context = (StreamingContext)args[1]; ! ! if( _target==null & _session!=null ) { ! Key key = new Key(_id, _session.Factory.GetPersister( _persistentClass ) ); _target = _session.GetEntity( key ); } --- 186,202 ---- /// which indicates that the Proxy will need to forward to the real implementation. /// </returns> ! public virtual object Invoke( MethodBase method, params object[ ] args ) { // if the Proxy Engine delegates the call of GetObjectData to the Initializer // then we need to handle it. Castle.DynamicProxy takes care of serializing // proxies for us, but other providers might not. ! if( method.Name.Equals( "GetObjectData" ) ) { ! SerializationInfo info = ( SerializationInfo ) args[ 0 ]; ! StreamingContext context = ( StreamingContext ) args[ 1 ]; // not used !?! ! ! if( _target == null & _session != null ) { ! Key key = new Key( _id, _session.Factory.GetPersister( _persistentClass ) ); _target = _session.GetEntity( key ); } *************** *** 204,208 **** return null; } ! else if( !_overridesEquals && _identifierPropertyInfo!=null && method.Name.Equals("GetHashCode") ) { // kinda dodgy, since it redefines the hashcode of the proxied object. --- 209,213 ---- return null; } ! else if( !_overridesEquals && _identifierPropertyInfo != null && method.Name.Equals( "GetHashCode" ) ) { // kinda dodgy, since it redefines the hashcode of the proxied object. *************** *** 211,230 **** return _id.GetHashCode(); } ! else if( _identifierPropertyInfo!=null && method.Equals( _identifierPropertyInfo.GetGetMethod(true) ) ) { return _id; } ! else if( method.Name.Equals( "Dispose" ) ) { return null; } ! else if ( args.Length==1 && !_overridesEquals && _identifierPropertyInfo!=null && method.Name.Equals( "Equals" ) ) { // less dodgy because NHibernate forces == to be the same as Identifier Equals ! return _id.Equals( _identifierPropertyInfo.GetValue( _target, null ) ); } ! ! else { return InvokeImplementation; --- 216,235 ---- return _id.GetHashCode(); } ! else if( _identifierPropertyInfo != null && method.Equals( _identifierPropertyInfo.GetGetMethod( true ) ) ) { return _id; } ! else if( method.Name.Equals( "Dispose" ) ) { return null; } ! else if( args.Length == 1 && !_overridesEquals && _identifierPropertyInfo != null && method.Name.Equals( "Equals" ) ) { // less dodgy because NHibernate forces == to be the same as Identifier Equals ! return _id.Equals( _identifierPropertyInfo.GetValue( _target, null ) ); } ! ! else { return InvokeImplementation; *************** *** 233,235 **** } } ! } --- 238,240 ---- } } ! } \ No newline at end of file Index: IProxyGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/IProxyGenerator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IProxyGenerator.cs 9 Dec 2004 17:52:16 -0000 1.2 --- IProxyGenerator.cs 31 Dec 2004 22:08:25 -0000 1.3 *************** *** 1,5 **** - using System; using System.Reflection; - using NHibernate.Engine; --- 1,3 ---- *************** *** 11,15 **** public interface IProxyGenerator { - /// <summary> /// Build a proxy using the Castle.DynamicProxy library. --- 9,12 ---- *************** *** 20,25 **** /// <param name="id">The value for the Id.</param> /// <param name="session">The Session the proxy is in.</param> /// <returns>A fully built <c>INHibernateProxy</c>.</returns> ! INHibernateProxy GetProxy(System.Type persistentClass, System.Type concreteProxy, System.Type[] interfaces, PropertyInfo identifierPropertyInfo, object id, ISessionImplementor session); /// <summary> --- 17,23 ---- /// <param name="id">The value for the Id.</param> /// <param name="session">The Session the proxy is in.</param> + /// <param name="concreteProxy"></param> /// <returns>A fully built <c>INHibernateProxy</c>.</returns> ! INHibernateProxy GetProxy( System.Type persistentClass, System.Type concreteProxy, System.Type[ ] interfaces, PropertyInfo identifierPropertyInfo, object id, ISessionImplementor session ); /// <summary> *************** *** 28,32 **** /// <param name="proxy">The Proxy object</param> /// <returns>The <see cref="LazyInitializer"/> that contains the details of the Proxied object.</returns> ! LazyInitializer GetLazyInitializer(INHibernateProxy proxy); /// <summary> --- 26,30 ---- /// <param name="proxy">The Proxy object</param> /// <returns>The <see cref="LazyInitializer"/> that contains the details of the Proxied object.</returns> ! LazyInitializer GetLazyInitializer( INHibernateProxy proxy ); /// <summary> *************** *** 36,40 **** /// <param name="obj">The object to get the type of.</param> /// <returns>The Underlying Type for the object regardless of if it is a Proxy.</returns> ! System.Type GetClass(object obj); } ! } --- 34,38 ---- /// <param name="obj">The object to get the type of.</param> /// <returns>The Underlying Type for the object regardless of if it is a Proxy.</returns> ! System.Type GetClass( object obj ); } ! } \ No newline at end of file Index: INHibernateProxy.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/INHibernateProxy.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** INHibernateProxy.cs 16 Dec 2004 21:51:48 -0000 1.3 --- INHibernateProxy.cs 31 Dec 2004 22:08:25 -0000 1.4 *************** *** 1,4 **** - using System; - namespace NHibernate.Proxy { --- 1,2 ---- *************** *** 21,23 **** { } ! } --- 19,21 ---- { } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 22:08:20
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6624 Modified Files: CastleCustomProxyGenerator.cs CastleLazyInitializer.cs CastleProxyGenerator.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: CastleLazyInitializer.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/CastleLazyInitializer.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CastleLazyInitializer.cs 16 Dec 2004 21:51:48 -0000 1.2 --- CastleLazyInitializer.cs 31 Dec 2004 22:08:10 -0000 1.3 *************** *** 1,7 **** using System; using System.Reflection; - using Castle.DynamicProxy; ! using NHibernate.Engine; --- 1,6 ---- using System; using System.Reflection; using Castle.DynamicProxy; ! using log4net; using NHibernate.Engine; *************** *** 12,22 **** /// </summary> [Serializable] ! [CLSCompliant(false)] ! public class CastleLazyInitializer : LazyInitializer, Castle.DynamicProxy.IInterceptor//, ISerializable { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(CastleLazyInitializer) ); ! private System.Type _concreteProxy; ! private System.Type[] _interfaces; /// <summary> --- 11,21 ---- /// </summary> [Serializable] ! [CLSCompliant( false )] ! public class CastleLazyInitializer : LazyInitializer, Castle.DynamicProxy.IInterceptor //, ISerializable { ! private static readonly ILog log = LogManager.GetLogger( typeof( CastleLazyInitializer ) ); ! private System.Type _concreteProxy; // not used !?! ! private System.Type[ ] _interfaces; // not used !?! /// <summary> *************** *** 29,34 **** /// <param name="identifierPropertyInfo">The PropertyInfo for the <id> property.</param> /// <param name="session">The ISession this Proxy is in.</param> ! internal CastleLazyInitializer(System.Type persistentClass, System.Type concreteProxy, System.Type[] interfaces, object id, PropertyInfo identifierPropertyInfo, ISessionImplementor session) ! : base (persistentClass, id, identifierPropertyInfo, session) { _concreteProxy = concreteProxy; --- 28,33 ---- /// <param name="identifierPropertyInfo">The PropertyInfo for the <id> property.</param> /// <param name="session">The ISession this Proxy is in.</param> ! internal CastleLazyInitializer( System.Type persistentClass, System.Type concreteProxy, System.Type[ ] interfaces, object id, PropertyInfo identifierPropertyInfo, ISessionImplementor session ) ! : base( persistentClass, id, identifierPropertyInfo, session ) { _concreteProxy = concreteProxy; *************** *** 45,62 **** /// <param name="args">The parameters for the Method/Property</param> /// <returns>The result just like the actual object was called.</returns> ! public object Intercept(IInvocation invocation, params object[] args) { // let the generic LazyInitializer figure out if this can be handled // with the proxy or if the real class needs to be initialized ! object result = base.Invoke( invocation.Method, args); // the base LazyInitializer could not handle it so we need to Invoke // the method/property against the real class ! if( result==InvokeImplementation ) { invocation.InvocationTarget = GetImplementation(); return invocation.Proceed( args ); } ! else { return result; --- 44,61 ---- /// <param name="args">The parameters for the Method/Property</param> /// <returns>The result just like the actual object was called.</returns> ! public object Intercept( IInvocation invocation, params object[ ] args ) { // let the generic LazyInitializer figure out if this can be handled // with the proxy or if the real class needs to be initialized ! object result = base.Invoke( invocation.Method, args ); // the base LazyInitializer could not handle it so we need to Invoke // the method/property against the real class ! if( result == InvokeImplementation ) { invocation.InvocationTarget = GetImplementation(); return invocation.Proceed( args ); } ! else { return result; *************** *** 65,69 **** #endregion - } ! } --- 64,67 ---- #endregion } ! } \ No newline at end of file Index: CastleProxyGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/CastleProxyGenerator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CastleProxyGenerator.cs 16 Dec 2004 21:51:48 -0000 1.2 --- CastleProxyGenerator.cs 31 Dec 2004 22:08:10 -0000 1.3 *************** *** 2,11 **** using System.Collections; using System.Reflection; - using System.Reflection.Emit; - using Castle.DynamicProxy; - using Castle.DynamicProxy.Builder; using Castle.DynamicProxy.Builder.CodeGenerators; ! using NHibernate.Engine; --- 2,8 ---- using System.Collections; using System.Reflection; using Castle.DynamicProxy; using Castle.DynamicProxy.Builder.CodeGenerators; ! using log4net; using NHibernate.Engine; *************** *** 17,21 **** public class CastleProxyGenerator : IProxyGenerator { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(CastleProxyGenerator) ); // key = mapped type --- 14,18 ---- public class CastleProxyGenerator : IProxyGenerator { ! private static readonly ILog log = LogManager.GetLogger( typeof( CastleProxyGenerator ) ); // key = mapped type *************** *** 37,41 **** // the EnhanceTypeDelegate will add custom code gen that DynamicProxy does not provide // by default. ! _context = new GeneratorContext( );// new EnhanceTypeDelegate( EnhanceInterfaceType ), null ); } --- 34,38 ---- // the EnhanceTypeDelegate will add custom code gen that DynamicProxy does not provide // by default. ! _context = new GeneratorContext(); // new EnhanceTypeDelegate( EnhanceInterfaceType ), null ); } *************** *** 49,59 **** /// <param name="identifierPropertyInfo">The PropertyInfo to get/set the Id.</param> /// <param name="id">The value for the Id.</param> /// <param name="session">The Session the proxy is in.</param> /// <returns>A fully built <c>INHibernateProxy</c>.</returns> ! public INHibernateProxy GetProxy(System.Type persistentClass, System.Type concreteProxy, System.Type[] interfaces, PropertyInfo identifierPropertyInfo, object id, ISessionImplementor session) { object generatedProxy = null; ! try ! { CastleLazyInitializer initializer = new CastleLazyInitializer( persistentClass, concreteProxy, interfaces, id, identifierPropertyInfo, session ); System.Type proxyType = null; --- 46,57 ---- /// <param name="identifierPropertyInfo">The PropertyInfo to get/set the Id.</param> /// <param name="id">The value for the Id.</param> + /// <param name="concreteProxy"></param> /// <param name="session">The Session the proxy is in.</param> /// <returns>A fully built <c>INHibernateProxy</c>.</returns> ! public INHibernateProxy GetProxy( System.Type persistentClass, System.Type concreteProxy, System.Type[ ] interfaces, PropertyInfo identifierPropertyInfo, object id, ISessionImplementor session ) { object generatedProxy = null; ! try ! { CastleLazyInitializer initializer = new CastleLazyInitializer( persistentClass, concreteProxy, interfaces, id, identifierPropertyInfo, session ); System.Type proxyType = null; *************** *** 63,67 **** // to define the same type twice in it. So nh needs to keep a cache of the proxy types that have // already been generated. ! lock( cachedProxyTypes.SyncRoot ) { proxyType = cachedProxyTypes[ concreteProxy ] as System.Type; --- 61,65 ---- // to define the same type twice in it. So nh needs to keep a cache of the proxy types that have // already been generated. ! lock( cachedProxyTypes.SyncRoot ) { proxyType = cachedProxyTypes[ concreteProxy ] as System.Type; *************** *** 72,87 **** if( concreteProxy.IsInterface ) { ! if( proxyType==null ) { //TODO: figure out if this is necessary because the concreteProxy is // already included in the interfaces array... ! System.Type[] temp = new System.Type[ interfaces.Length + 1 ]; interfaces.CopyTo( temp, 0 ); temp[ interfaces.Length ] = concreteProxy; //persistentClass; interfaces = temp; ! InterfaceProxyGenerator _interfaceGenerator = new InterfaceProxyGenerator( _scope, _context ); proxyType = _interfaceGenerator.GenerateCode( interfaces ); ! cachedProxyTypes[ concreteProxy ] = proxyType; } --- 70,85 ---- if( concreteProxy.IsInterface ) { ! if( proxyType == null ) { //TODO: figure out if this is necessary because the concreteProxy is // already included in the interfaces array... ! System.Type[ ] temp = new System.Type[interfaces.Length + 1]; interfaces.CopyTo( temp, 0 ); temp[ interfaces.Length ] = concreteProxy; //persistentClass; interfaces = temp; ! InterfaceProxyGenerator _interfaceGenerator = new InterfaceProxyGenerator( _scope, _context ); proxyType = _interfaceGenerator.GenerateCode( interfaces ); ! cachedProxyTypes[ concreteProxy ] = proxyType; } *************** *** 90,117 **** // hack with new object() because an interface proxy is expecting an actual target instance - we // don't have that yet and don't want to create it until it is actually needed. ! generatedProxy = Activator.CreateInstance( proxyType, new object[] { initializer, new object() } ); ! } ! else { ! if( proxyType==null ) { CastleCustomProxyGenerator _classGenerator = new CastleCustomProxyGenerator( _scope, _context ); proxyType = _classGenerator.GenerateCode( concreteProxy ); ! cachedProxyTypes[ concreteProxy ] = proxyType; } ! ! generatedProxy = Activator.CreateInstance( proxyType, new object[] { initializer } ); ! } } ! return (INHibernateProxy)generatedProxy; } ! catch(Exception e) { ! log.Error("Castle Dynamic Class Generator failed", e); ! throw new HibernateException( "Castle Dynamic Class Generator failed", e); } } --- 88,115 ---- // hack with new object() because an interface proxy is expecting an actual target instance - we // don't have that yet and don't want to create it until it is actually needed. ! generatedProxy = Activator.CreateInstance( proxyType, new object[ ] {initializer, new object()} ); ! } ! else { ! if( proxyType == null ) { CastleCustomProxyGenerator _classGenerator = new CastleCustomProxyGenerator( _scope, _context ); proxyType = _classGenerator.GenerateCode( concreteProxy ); ! cachedProxyTypes[ concreteProxy ] = proxyType; } ! ! generatedProxy = Activator.CreateInstance( proxyType, new object[ ] {initializer} ); ! } } ! return ( INHibernateProxy ) generatedProxy; } ! catch( Exception e ) { ! log.Error( "Castle Dynamic Class Generator failed", e ); ! throw new HibernateException( "Castle Dynamic Class Generator failed", e ); } } *************** *** 122,126 **** /// <param name="proxy">The Proxy object</param> /// <returns>The <see cref="LazyInitializer"/> that contains the details of the Proxied object.</returns> ! public LazyInitializer GetLazyInitializer(INHibernateProxy proxy) { // have to hard code in "__interceptor" - very dependant on them not changing their --- 120,124 ---- /// <param name="proxy">The Proxy object</param> /// <returns>The <see cref="LazyInitializer"/> that contains the details of the Proxied object.</returns> ! public LazyInitializer GetLazyInitializer( INHibernateProxy proxy ) { // have to hard code in "__interceptor" - very dependant on them not changing their *************** *** 128,132 **** // field object fieldValue = proxy.GetType().GetField( "__interceptor" ).GetValue( proxy ); ! return (LazyInitializer)fieldValue; } --- 126,130 ---- // field object fieldValue = proxy.GetType().GetField( "__interceptor" ).GetValue( proxy ); ! return ( LazyInitializer ) fieldValue; } *************** *** 137,149 **** /// <param name="obj">The object to get the type of.</param> /// <returns>The Underlying Type for the object regardless of if it is a Proxy.</returns> ! public System.Type GetClass(object obj) { ! if (obj is INHibernateProxy) { ! INHibernateProxy proxy = (INHibernateProxy) obj; LazyInitializer li = GetLazyInitializer( proxy ); return li.PersistentClass; } ! else { return obj.GetType(); --- 135,147 ---- /// <param name="obj">The object to get the type of.</param> /// <returns>The Underlying Type for the object regardless of if it is a Proxy.</returns> ! public System.Type GetClass( object obj ) { ! if( obj is INHibernateProxy ) { ! INHibernateProxy proxy = ( INHibernateProxy ) obj; LazyInitializer li = GetLazyInitializer( proxy ); return li.PersistentClass; } ! else { return obj.GetType(); *************** *** 153,155 **** #endregion } ! } --- 151,153 ---- #endregion } ! } \ No newline at end of file Index: CastleCustomProxyGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Proxy/CastleCustomProxyGenerator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CastleCustomProxyGenerator.cs 16 Dec 2004 21:51:48 -0000 1.2 --- CastleCustomProxyGenerator.cs 31 Dec 2004 22:08:10 -0000 1.3 *************** *** 1,4 **** using System; - using Castle.DynamicProxy; using Castle.DynamicProxy.Builder.CodeBuilder; --- 1,3 ---- *************** *** 12,25 **** /// interface to it. /// </summary> ! [CLSCompliant(false)] public class CastleCustomProxyGenerator : ClassProxyGenerator { ! public CastleCustomProxyGenerator(ModuleScope scope) ! : base(scope) { } ! public CastleCustomProxyGenerator(ModuleScope scope, GeneratorContext context) ! : base(scope, context) { } --- 11,33 ---- /// interface to it. /// </summary> ! [CLSCompliant( false )] public class CastleCustomProxyGenerator : ClassProxyGenerator { ! /// <summary> ! /// ! /// </summary> ! /// <param name="scope"></param> ! public CastleCustomProxyGenerator( ModuleScope scope ) ! : base( scope ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="scope"></param> ! /// <param name="context"></param> ! public CastleCustomProxyGenerator( ModuleScope scope, GeneratorContext context ) ! : base( scope, context ) { } *************** *** 31,35 **** /// <param name="interfaces">The extra <see cref="System.Type"/> interfaces for the Proxy to implement.</param> /// <returns>An <see cref="EasyType"/> with the required interfaces added.</returns> ! protected override EasyType CreateTypeBuilder(System.Type baseType, System.Type[] interfaces) { bool isImplemented = false; --- 39,43 ---- /// <param name="interfaces">The extra <see cref="System.Type"/> interfaces for the Proxy to implement.</param> /// <returns>An <see cref="EasyType"/> with the required interfaces added.</returns> ! protected override EasyType CreateTypeBuilder( System.Type baseType, System.Type[ ] interfaces ) { bool isImplemented = false; *************** *** 37,43 **** // check to see if this implements INHibernateProxy - if not then make it // implement the interface ! for( int i=0; i<interfaces.Length; i++) { ! if( interfaces[i].Equals( typeof(INHibernateProxy) ) ) { isImplemented = true; --- 45,51 ---- // check to see if this implements INHibernateProxy - if not then make it // implement the interface ! for( int i = 0; i < interfaces.Length; i++ ) { ! if( interfaces[ i ].Equals( typeof( INHibernateProxy ) ) ) { isImplemented = true; *************** *** 45,60 **** } ! if( isImplemented==false ) { int length = interfaces.Length; ! System.Type[] newInterfaces = new System.Type[ length + 1 ]; Array.Copy( interfaces, 0, newInterfaces, 0, length ); ! newInterfaces[ length ] = typeof(INHibernateProxy); interfaces = newInterfaces; } ! return base.CreateTypeBuilder(baseType, interfaces); } } ! } --- 53,68 ---- } ! if( isImplemented == false ) { int length = interfaces.Length; ! System.Type[ ] newInterfaces = new System.Type[length + 1]; Array.Copy( interfaces, 0, newInterfaces, 0, length ); ! newInterfaces[ length ] = typeof( INHibernateProxy ); interfaces = newInterfaces; } ! return base.CreateTypeBuilder( baseType, interfaces ); } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 21:56:45
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Property In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4736 Modified Files: NoSetterAccessor.cs PascalCaseMUnderscoreStrategy.cs PropertyAccessorFactory.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: NoSetterAccessor.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/NoSetterAccessor.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NoSetterAccessor.cs 23 Aug 2004 13:15:37 -0000 1.1 --- NoSetterAccessor.cs 31 Dec 2004 21:56:35 -0000 1.2 *************** *** 1,5 **** - using System; - using System.Reflection; - namespace NHibernate.Property { --- 1,2 ---- *************** *** 15,37 **** public class NoSetterAccessor : IPropertyAccessor { ! IFieldNamingStrategy namingStrategy; ! public NoSetterAccessor(IFieldNamingStrategy namingStrategy) { this.namingStrategy = namingStrategy; } ! #region IPropertyAccessor Members ! public IGetter GetGetter(System.Type theClass, string propertyName) { ! BasicGetter result = BasicPropertyAccessor.GetGetterOrNull(theClass, propertyName); ! if (result == null) throw new PropertyNotFoundException( "Could not find a setter for property " + propertyName + " in class " + theClass.FullName ); return result; } ! public ISetter GetSetter(System.Type theClass, string propertyName) { ! string fieldName = namingStrategy.GetFieldName(propertyName); return new FieldSetter( FieldAccessor.GetField( theClass, fieldName ), theClass, fieldName ); } --- 12,53 ---- public class NoSetterAccessor : IPropertyAccessor { ! private IFieldNamingStrategy namingStrategy; ! /// <summary> ! /// ! /// </summary> ! /// <param name="namingStrategy"></param> ! public NoSetterAccessor( IFieldNamingStrategy namingStrategy ) { this.namingStrategy = namingStrategy; } ! #region IPropertyAccessor Members ! /// <summary> ! /// ! /// </summary> ! /// <param name="theClass"></param> ! /// <param name="propertyName"></param> ! /// <returns></returns> ! public IGetter GetGetter( System.Type theClass, string propertyName ) { ! BasicGetter result = BasicPropertyAccessor.GetGetterOrNull( theClass, propertyName ); ! if( result == null ) ! { ! throw new PropertyNotFoundException( "Could not find a setter for property " + propertyName + " in class " + theClass.FullName ); ! } return result; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="theClass"></param> ! /// <param name="propertyName"></param> ! /// <returns></returns> ! public ISetter GetSetter( System.Type theClass, string propertyName ) { ! string fieldName = namingStrategy.GetFieldName( propertyName ); return new FieldSetter( FieldAccessor.GetField( theClass, fieldName ), theClass, fieldName ); } *************** *** 39,41 **** #endregion } ! } --- 55,57 ---- #endregion } ! } \ No newline at end of file Index: PropertyAccessorFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/PropertyAccessorFactory.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PropertyAccessorFactory.cs 22 Nov 2004 03:52:17 -0000 1.7 --- PropertyAccessorFactory.cs 31 Dec 2004 21:56:35 -0000 1.8 *************** *** 1,6 **** using System; using System.Collections; - using System.Reflection; - using NHibernate.Util; --- 1,4 ---- *************** *** 13,35 **** { private static IDictionary accessors; ! ! static PropertyAccessorFactory() { ! accessors = new Hashtable(13); ! accessors["property"] = new BasicPropertyAccessor(); ! accessors["field"] = new FieldAccessor(); ! accessors["field.camelcase"] = new FieldAccessor( new CamelCaseStrategy() ); ! accessors["field.camelcase-underscore"] = new FieldAccessor( new CamelCaseUnderscoreStrategy() ); ! accessors["field.pascalcase-m-underscore"] = new FieldAccessor( new PascalCaseMUnderscoreStrategy() ) ; ! accessors["field.lowercase-underscore"] = new FieldAccessor( new LowerCaseUnderscoreStrategy() ); ! accessors["nosetter.camelcase"] = new NoSetterAccessor( new CamelCaseStrategy() ); ! accessors["nosetter.camelcase-underscore"] = new NoSetterAccessor( new CamelCaseUnderscoreStrategy() ); ! accessors["nosetter.pascalcase-m-underscore"] = new NoSetterAccessor( new PascalCaseMUnderscoreStrategy() ); ! accessors["nosetter.lowercase-underscore"] = new NoSetterAccessor( new LowerCaseUnderscoreStrategy() ); } private PropertyAccessorFactory() { ! throw new NotSupportedException("Should not be creating a PropertyAccessorFactory - only use the static methods."); } --- 11,34 ---- { private static IDictionary accessors; ! ! /// <summary></summary> ! static PropertyAccessorFactory() { ! accessors = new Hashtable( 13 ); ! accessors[ "property" ] = new BasicPropertyAccessor(); ! accessors[ "field" ] = new FieldAccessor(); ! accessors[ "field.camelcase" ] = new FieldAccessor( new CamelCaseStrategy() ); ! accessors[ "field.camelcase-underscore" ] = new FieldAccessor( new CamelCaseUnderscoreStrategy() ); ! accessors[ "field.pascalcase-m-underscore" ] = new FieldAccessor( new PascalCaseMUnderscoreStrategy() ); ! accessors[ "field.lowercase-underscore" ] = new FieldAccessor( new LowerCaseUnderscoreStrategy() ); ! accessors[ "nosetter.camelcase" ] = new NoSetterAccessor( new CamelCaseStrategy() ); ! accessors[ "nosetter.camelcase-underscore" ] = new NoSetterAccessor( new CamelCaseUnderscoreStrategy() ); ! accessors[ "nosetter.pascalcase-m-underscore" ] = new NoSetterAccessor( new PascalCaseMUnderscoreStrategy() ); ! accessors[ "nosetter.lowercase-underscore" ] = new NoSetterAccessor( new LowerCaseUnderscoreStrategy() ); } private PropertyAccessorFactory() { ! throw new NotSupportedException( "Should not be creating a PropertyAccessorFactory - only use the static methods." ); } *************** *** 38,42 **** /// </summary> /// <value>An <see cref="IDictionary"/> of the built in <see cref="IPropertyAccessor"/> strategies.</value> ! public static IDictionary PropertyAccessors { get { return accessors; } --- 37,41 ---- /// </summary> /// <value>An <see cref="IDictionary"/> of the built in <see cref="IPropertyAccessor"/> strategies.</value> ! public static IDictionary PropertyAccessors { get { return accessors; } *************** *** 144,152 **** /// </para> /// </remarks> ! public static IPropertyAccessor GetPropertyAccessor(string type) { // if not type is specified then fall back to the default of using // the property. ! if( type==null ) { type = "property"; --- 143,151 ---- /// </para> /// </remarks> ! public static IPropertyAccessor GetPropertyAccessor( string type ) { // if not type is specified then fall back to the default of using // the property. ! if( type == null ) { type = "property"; *************** *** 154,185 **** // attempt to find it in the built in types ! IPropertyAccessor accessor = accessors[type] as IPropertyAccessor; ! if( accessor!=null ) { return accessor; } ! // was not a built in type so now check to see if it is custom // accessor. System.Type accessorClass; ! try { ! accessorClass = ReflectHelper.ClassForName(type); } ! catch(TypeLoadException tle) { ! throw new MappingException("could not find PropertyAccessor type: " + type, tle); } ! try { ! return (IPropertyAccessor) Activator.CreateInstance(accessorClass); } ! catch(Exception e) { ! throw new MappingException("could not instantiate PropertyAccessor type: " + type, e ); } } } ! } --- 153,184 ---- // attempt to find it in the built in types ! IPropertyAccessor accessor = accessors[ type ] as IPropertyAccessor; ! if( accessor != null ) { return accessor; } ! // was not a built in type so now check to see if it is custom // accessor. System.Type accessorClass; ! try { ! accessorClass = ReflectHelper.ClassForName( type ); } ! catch( TypeLoadException tle ) { ! throw new MappingException( "could not find PropertyAccessor type: " + type, tle ); } ! try { ! return ( IPropertyAccessor ) Activator.CreateInstance( accessorClass ); } ! catch( Exception e ) { ! throw new MappingException( "could not instantiate PropertyAccessor type: " + type, e ); } } } ! } \ No newline at end of file Index: PascalCaseMUnderscoreStrategy.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/PascalCaseMUnderscoreStrategy.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PascalCaseMUnderscoreStrategy.cs 23 Aug 2004 13:11:08 -0000 1.2 --- PascalCaseMUnderscoreStrategy.cs 31 Dec 2004 21:56:35 -0000 1.3 *************** *** 1,4 **** - using System; - namespace NHibernate.Property { --- 1,2 ---- *************** *** 9,21 **** public class PascalCaseMUnderscoreStrategy : IFieldNamingStrategy { - #region IFieldNamingStrategy Members ! public string GetFieldName(string propertyName) { ! return "m_" + propertyName.Substring(0, 1).ToUpper() + propertyName.Substring(1); } #endregion } ! } --- 7,23 ---- public class PascalCaseMUnderscoreStrategy : IFieldNamingStrategy { #region IFieldNamingStrategy Members ! /// <summary> ! /// ! /// </summary> ! /// <param name="propertyName"></param> ! /// <returns></returns> ! public string GetFieldName( string propertyName ) { ! return "m_" + propertyName.Substring( 0, 1 ).ToUpper() + propertyName.Substring( 1 ); } #endregion } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 21:56:34
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Property In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4700 Modified Files: IGetter.cs IPropertyAccessor.cs ISetter.cs LowerCaseUnderscoreStrategy.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: IGetter.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/IGetter.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IGetter.cs 22 Aug 2004 06:18:54 -0000 1.1 --- IGetter.cs 31 Dec 2004 21:56:23 -0000 1.2 *************** *** 1,3 **** - using System; using System.Reflection; --- 1,2 ---- *************** *** 14,18 **** /// <param name="target"></param> /// <returns></returns> ! object Get(object target); /// <summary> --- 13,17 ---- /// <param name="target"></param> /// <returns></returns> ! object Get( object target ); /// <summary> *************** *** 20,24 **** /// </summary> /// <returns></returns> ! System.Type ReturnType{ get; } /// <summary> --- 19,23 ---- /// </summary> /// <returns></returns> ! System.Type ReturnType { get; } /// <summary> *************** *** 26,30 **** /// </summary> /// <returns></returns> ! string PropertyName { get; } /// <summary> --- 25,29 ---- /// </summary> /// <returns></returns> ! string PropertyName { get; } /// <summary> *************** *** 38,40 **** PropertyInfo Property { get; } } ! } --- 37,39 ---- PropertyInfo Property { get; } } ! } \ No newline at end of file Index: ISetter.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/ISetter.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ISetter.cs 22 Aug 2004 06:18:54 -0000 1.1 --- ISetter.cs 31 Dec 2004 21:56:23 -0000 1.2 *************** *** 1,3 **** - using System; using System.Reflection; --- 1,2 ---- *************** *** 16,20 **** /// <exception cref="HibernateException"> /// </exception> ! void Set(object target, object value); /// <summary> --- 15,19 ---- /// <exception cref="HibernateException"> /// </exception> ! void Set( object target, object value ); /// <summary> *************** *** 34,36 **** PropertyInfo Property { get; } } ! } --- 33,35 ---- PropertyInfo Property { get; } } ! } \ No newline at end of file Index: LowerCaseUnderscoreStrategy.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/LowerCaseUnderscoreStrategy.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LowerCaseUnderscoreStrategy.cs 23 Oct 2004 15:44:08 -0000 1.1 --- LowerCaseUnderscoreStrategy.cs 31 Dec 2004 21:56:23 -0000 1.2 *************** *** 1,4 **** - using System; - namespace NHibernate.Property { --- 1,2 ---- *************** *** 7,15 **** /// an underscore and the PropertyName is changed to lower case. /// </summary> ! public class LowerCaseUnderscoreStrategy : IFieldNamingStrategy { #region IFieldNamingStrategy Members ! public string GetFieldName(string propertyName) { return "_" + propertyName.ToLower(); --- 5,18 ---- /// an underscore and the PropertyName is changed to lower case. /// </summary> ! public class LowerCaseUnderscoreStrategy : IFieldNamingStrategy { #region IFieldNamingStrategy Members ! /// <summary> ! /// ! /// </summary> ! /// <param name="propertyName"></param> ! /// <returns></returns> ! public string GetFieldName( string propertyName ) { return "_" + propertyName.ToLower(); *************** *** 18,22 **** #endregion } ! } ! ! --- 21,23 ---- #endregion } ! } \ No newline at end of file Index: IPropertyAccessor.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/IPropertyAccessor.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IPropertyAccessor.cs 22 Aug 2004 06:18:54 -0000 1.1 --- IPropertyAccessor.cs 31 Dec 2004 21:56:23 -0000 1.2 *************** *** 1,4 **** - using System; - namespace NHibernate.Property { --- 1,2 ---- *************** *** 17,22 **** /// <exception cref="PropertyNotFoundException" > /// </exception> ! IGetter GetGetter(System.Type theClass, string propertyName); ! /// <summary> /// Create a "setter" for the named attribute --- 15,20 ---- /// <exception cref="PropertyNotFoundException" > /// </exception> ! IGetter GetGetter( System.Type theClass, string propertyName ); ! /// <summary> /// Create a "setter" for the named attribute *************** *** 27,31 **** /// <exception cref="PropertyNotFoundException" > /// </exception> ! ISetter GetSetter(System.Type theClass, string propertyName); } ! } --- 25,29 ---- /// <exception cref="PropertyNotFoundException" > /// </exception> ! ISetter GetSetter( System.Type theClass, string propertyName ); } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 21:56:20
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Property In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4661 Modified Files: FieldGetter.cs FieldSetter.cs IFieldNamingStrategy.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: FieldGetter.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/FieldGetter.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FieldGetter.cs 23 Oct 2004 15:01:21 -0000 1.2 --- FieldGetter.cs 31 Dec 2004 21:56:10 -0000 1.3 *************** *** 4,7 **** --- 4,8 ---- namespace NHibernate.Property { + /// <summary></summary> public sealed class FieldGetter : IGetter { *************** *** 10,14 **** private readonly string name; ! public FieldGetter(FieldInfo field, System.Type clazz, string name) { this.field = field; --- 11,21 ---- private readonly string name; ! /// <summary> ! /// ! /// </summary> ! /// <param name="field"></param> ! /// <param name="clazz"></param> ! /// <param name="name"></param> ! public FieldGetter( FieldInfo field, System.Type clazz, string name ) { this.field = field; *************** *** 19,29 **** #region IGetter Members ! public object Get(object target) { ! try { ! return field.GetValue(target); } ! catch(Exception e) { throw new PropertyAccessException( e, "could not get a field value by reflection", false, clazz, name ); --- 26,41 ---- #region IGetter Members ! /// <summary> ! /// ! /// </summary> ! /// <param name="target"></param> ! /// <returns></returns> ! public object Get( object target ) { ! try { ! return field.GetValue( target ); } ! catch( Exception e ) { throw new PropertyAccessException( e, "could not get a field value by reflection", false, clazz, name ); *************** *** 31,34 **** --- 43,47 ---- } + /// <summary></summary> public System.Type ReturnType { *************** *** 36,39 **** --- 49,53 ---- } + /// <summary></summary> public string PropertyName { *************** *** 41,44 **** --- 55,59 ---- } + /// <summary></summary> public PropertyInfo Property { *************** *** 48,50 **** #endregion } ! } --- 63,65 ---- #endregion } ! } \ No newline at end of file Index: FieldSetter.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/FieldSetter.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FieldSetter.cs 22 Aug 2004 06:18:54 -0000 1.1 --- FieldSetter.cs 31 Dec 2004 21:56:10 -0000 1.2 *************** *** 4,7 **** --- 4,8 ---- namespace NHibernate.Property { + /// <summary></summary> public sealed class FieldSetter : ISetter { *************** *** 10,14 **** private readonly string name; ! public FieldSetter(FieldInfo field, System.Type clazz, string name) { this.field = field; --- 11,21 ---- private readonly string name; ! /// <summary> ! /// ! /// </summary> ! /// <param name="field"></param> ! /// <param name="clazz"></param> ! /// <param name="name"></param> ! public FieldSetter( FieldInfo field, System.Type clazz, string name ) { this.field = field; *************** *** 19,35 **** #region ISetter Members ! public void Set(object target, object value) { ! try { field.SetValue( target, value ); } ! catch(Exception e) { ! throw new PropertyAccessException(e, "could not set a field value by reflection", true, clazz, name); } } ! public string PropertyName { --- 26,47 ---- #region ISetter Members ! /// <summary> ! /// ! /// </summary> ! /// <param name="target"></param> ! /// <param name="value"></param> ! public void Set( object target, object value ) { ! try { field.SetValue( target, value ); } ! catch( Exception e ) { ! throw new PropertyAccessException( e, "could not set a field value by reflection", true, clazz, name ); } } ! /// <summary></summary> public string PropertyName { *************** *** 37,40 **** --- 49,53 ---- } + /// <summary></summary> public PropertyInfo Property { *************** *** 45,47 **** } ! } --- 58,60 ---- } ! } \ No newline at end of file Index: IFieldNamingStrategy.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/IFieldNamingStrategy.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IFieldNamingStrategy.cs 23 Aug 2004 02:10:06 -0000 1.1 --- IFieldNamingStrategy.cs 31 Dec 2004 21:56:10 -0000 1.2 *************** *** 1,4 **** - using System; - namespace NHibernate.Property { --- 1,2 ---- *************** *** 13,17 **** /// <param name="propertyName">The name of the Property.</param> /// <returns>The name of the Field.</returns> ! string GetFieldName(string propertyName); } ! } --- 11,15 ---- /// <param name="propertyName">The name of the Property.</param> /// <returns>The name of the Field.</returns> ! string GetFieldName( string propertyName ); } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 21:55:59
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Property In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4573 Modified Files: CamelCaseStrategy.cs CamelCaseUnderscoreStrategy.cs FieldAccessor.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: CamelCaseStrategy.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/CamelCaseStrategy.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CamelCaseStrategy.cs 23 Aug 2004 02:10:06 -0000 1.1 --- CamelCaseStrategy.cs 31 Dec 2004 21:55:49 -0000 1.2 *************** *** 1,4 **** - using System; - namespace NHibernate.Property { --- 1,2 ---- *************** *** 9,21 **** public class CamelCaseStrategy : IFieldNamingStrategy { - #region IFieldNamingStrategy Members ! public string GetFieldName(string propertyName) { ! return propertyName.Substring(0, 1).ToLower() + propertyName.Substring(1); } #endregion } ! } --- 7,23 ---- public class CamelCaseStrategy : IFieldNamingStrategy { #region IFieldNamingStrategy Members ! /// <summary> ! /// ! /// </summary> ! /// <param name="propertyName"></param> ! /// <returns></returns> ! public string GetFieldName( string propertyName ) { ! return propertyName.Substring( 0, 1 ).ToLower() + propertyName.Substring( 1 ); } #endregion } ! } \ No newline at end of file Index: CamelCaseUnderscoreStrategy.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/CamelCaseUnderscoreStrategy.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CamelCaseUnderscoreStrategy.cs 23 Aug 2004 02:10:06 -0000 1.1 --- CamelCaseUnderscoreStrategy.cs 31 Dec 2004 21:55:49 -0000 1.2 *************** *** 1,4 **** - using System; - namespace NHibernate.Property { --- 1,2 ---- *************** *** 7,20 **** /// an underscore and the PropertyName is changed to camelCase. /// </summary> ! public class CamelCaseUnderscoreStrategy : IFieldNamingStrategy { #region IFieldNamingStrategy Members ! public string GetFieldName(string propertyName) { ! return "_" + propertyName.Substring(0, 1).ToLower() + propertyName.Substring(1); } #endregion } ! } --- 5,23 ---- /// an underscore and the PropertyName is changed to camelCase. /// </summary> ! public class CamelCaseUnderscoreStrategy : IFieldNamingStrategy { #region IFieldNamingStrategy Members ! /// <summary> ! /// ! /// </summary> ! /// <param name="propertyName"></param> ! /// <returns></returns> ! public string GetFieldName( string propertyName ) { ! return "_" + propertyName.Substring( 0, 1 ).ToLower() + propertyName.Substring( 1 ); } #endregion } ! } \ No newline at end of file Index: FieldAccessor.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/FieldAccessor.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FieldAccessor.cs 22 Nov 2004 03:56:00 -0000 1.5 --- FieldAccessor.cs 31 Dec 2004 21:55:49 -0000 1.6 *************** *** 1,3 **** - using System; using System.Reflection; --- 1,2 ---- *************** *** 17,25 **** private IFieldNamingStrategy namingStrategy; ! public FieldAccessor() { } ! public FieldAccessor(IFieldNamingStrategy namingStrategy) { this.namingStrategy = namingStrategy; --- 16,29 ---- private IFieldNamingStrategy namingStrategy; ! /// <summary></summary> ! public FieldAccessor() { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="namingStrategy"></param> ! public FieldAccessor( IFieldNamingStrategy namingStrategy ) { this.namingStrategy = namingStrategy; *************** *** 31,35 **** /// </summary> /// <value>The <see cref="IFieldNamingStrategy"/> or <c>null</c>.</value> ! public IFieldNamingStrategy NamingStrategy { get { return namingStrategy; } --- 35,39 ---- /// </summary> /// <value>The <see cref="IFieldNamingStrategy"/> or <c>null</c>.</value> ! public IFieldNamingStrategy NamingStrategy { get { return namingStrategy; } *************** *** 38,64 **** #region IPropertyAccessor Members ! public IGetter GetGetter(System.Type theClass, string propertyName) { ! string fieldName = GetFieldName(propertyName); return new FieldGetter( GetField( theClass, fieldName ), theClass, fieldName ); } ! public ISetter GetSetter(System.Type theClass, string propertyName) { ! string fieldName = GetFieldName(propertyName); return new FieldSetter( GetField( theClass, fieldName ), theClass, fieldName ); } #endregion ! ! internal static FieldInfo GetField(System.Type clazz, string fieldName) { ! if( clazz==null || clazz==typeof(object) ) { ! throw new PropertyNotFoundException("field not found: " + fieldName); } ! FieldInfo field = clazz.GetField( fieldName, BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.DeclaredOnly ); ! if(field==null) { field = GetField( clazz.BaseType, fieldName ); --- 42,86 ---- #region IPropertyAccessor Members ! /// <summary> ! /// ! /// </summary> ! /// <param name="theClass"></param> ! /// <param name="propertyName"></param> ! /// <returns></returns> ! public IGetter GetGetter( System.Type theClass, string propertyName ) { ! string fieldName = GetFieldName( propertyName ); return new FieldGetter( GetField( theClass, fieldName ), theClass, fieldName ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="theClass"></param> ! /// <param name="propertyName"></param> ! /// <returns></returns> ! public ISetter GetSetter( System.Type theClass, string propertyName ) { ! string fieldName = GetFieldName( propertyName ); return new FieldSetter( GetField( theClass, fieldName ), theClass, fieldName ); } #endregion ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="clazz"></param> ! /// <param name="fieldName"></param> ! /// <returns></returns> ! internal static FieldInfo GetField( System.Type clazz, string fieldName ) { ! if( clazz == null || clazz == typeof( object ) ) { ! throw new PropertyNotFoundException( "field not found: " + fieldName ); } ! FieldInfo field = clazz.GetField( fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly ); ! if( field == null ) { field = GetField( clazz.BaseType, fieldName ); *************** *** 79,93 **** /// This uses the convention that a Property named <c>Id</c> will have a field <c>id</c> /// </remarks> ! private string GetFieldName(string propertyName) { ! if( namingStrategy==null ) { return propertyName; } ! else { ! return namingStrategy.GetFieldName(propertyName); } } } ! } --- 101,115 ---- /// This uses the convention that a Property named <c>Id</c> will have a field <c>id</c> /// </remarks> ! private string GetFieldName( string propertyName ) { ! if( namingStrategy == null ) { return propertyName; } ! else { ! return namingStrategy.GetFieldName( propertyName ); } } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 21:55:48
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Property In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4531 Modified Files: BasicGetter.cs BasicPropertyAccessor.cs BasicSetter.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: BasicPropertyAccessor.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/BasicPropertyAccessor.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BasicPropertyAccessor.cs 23 Aug 2004 13:11:08 -0000 1.2 --- BasicPropertyAccessor.cs 31 Dec 2004 21:55:38 -0000 1.3 *************** *** 1,4 **** - using System; using System.Reflection; namespace NHibernate.Property --- 1,4 ---- using System.Reflection; + using log4net; namespace NHibernate.Property *************** *** 10,28 **** public class BasicPropertyAccessor : IPropertyAccessor { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(BasicPropertyAccessor)); ! #region IPropertyAccessor Members ! public ISetter GetSetter(System.Type type, string propertyName) { ! BasicSetter result = GetSetterOrNull(type, propertyName); ! if (result==null) throw new PropertyNotFoundException( "Could not find a setter for property " + propertyName + " in class " + type.FullName ); return result; } ! public IGetter GetGetter(System.Type theClass, string propertyName) { ! BasicGetter result = GetGetterOrNull(theClass, propertyName); ! if (result == null) throw new PropertyNotFoundException( "Could not find a setter for property " + propertyName + " in class " + theClass.FullName ); return result; } --- 10,46 ---- public class BasicPropertyAccessor : IPropertyAccessor { ! private static readonly ILog log = LogManager.GetLogger( typeof( BasicPropertyAccessor ) ); ! #region IPropertyAccessor Members ! /// <summary> ! /// ! /// </summary> ! /// <param name="type"></param> ! /// <param name="propertyName"></param> ! /// <returns></returns> ! public ISetter GetSetter( System.Type type, string propertyName ) { ! BasicSetter result = GetSetterOrNull( type, propertyName ); ! if( result == null ) ! { ! throw new PropertyNotFoundException( "Could not find a setter for property " + propertyName + " in class " + type.FullName ); ! } return result; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="theClass"></param> ! /// <param name="propertyName"></param> ! /// <returns></returns> ! public IGetter GetGetter( System.Type theClass, string propertyName ) { ! BasicGetter result = GetGetterOrNull( theClass, propertyName ); ! if( result == null ) ! { ! throw new PropertyNotFoundException( "Could not find a setter for property " + propertyName + " in class " + theClass.FullName ); ! } return result; } *************** *** 30,53 **** #endregion ! internal static BasicSetter GetSetterOrNull(System.Type type, string propertyName) { ! if (type == typeof(object) || type == null) return null; //PropertyInfo property = type.GetProperty(propertyName); ! PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.DeclaredOnly); ! if (property != null) { ! return new BasicSetter(type, property, propertyName); ! } ! else { BasicSetter setter = GetSetterOrNull( type.BaseType, propertyName ); ! if (setter == null) { ! System.Type[] interfaces = type.GetInterfaces(); ! for ( int i=0; setter==null && i<interfaces.Length; i++) { ! setter = GetSetterOrNull(interfaces[i], propertyName); } } --- 48,80 ---- #endregion ! /// <summary> ! /// ! /// </summary> ! /// <param name="type"></param> ! /// <param name="propertyName"></param> ! /// <returns></returns> ! internal static BasicSetter GetSetterOrNull( System.Type type, string propertyName ) { ! if( type == typeof( object ) || type == null ) ! { ! return null; ! } //PropertyInfo property = type.GetProperty(propertyName); ! PropertyInfo property = type.GetProperty( propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly ); ! if( property != null ) { ! return new BasicSetter( type, property, propertyName ); ! } ! else { BasicSetter setter = GetSetterOrNull( type.BaseType, propertyName ); ! if( setter == null ) { ! System.Type[ ] interfaces = type.GetInterfaces(); ! for( int i = 0; setter == null && i < interfaces.Length; i++ ) { ! setter = GetSetterOrNull( interfaces[ i ], propertyName ); } } *************** *** 55,79 **** } } ! ! internal static BasicGetter GetGetterOrNull(System.Type type, string propertyName) { ! if (type==typeof(object) || type==null) return null; //PropertyInfo property = type.GetProperty(propertyName); ! PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.DeclaredOnly); ! if (property != null) { ! return new BasicGetter(type, property, propertyName); ! } ! else { BasicGetter getter = GetGetterOrNull( type.BaseType, propertyName ); ! if (getter == null) { ! System.Type[] interfaces = type.GetInterfaces(); ! for (int i=0; getter==null && i<interfaces.Length; i++) { ! getter = GetGetterOrNull( interfaces[i], propertyName ); } } --- 82,115 ---- } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="type"></param> ! /// <param name="propertyName"></param> ! /// <returns></returns> ! internal static BasicGetter GetGetterOrNull( System.Type type, string propertyName ) { ! if( type == typeof( object ) || type == null ) ! { ! return null; ! } //PropertyInfo property = type.GetProperty(propertyName); ! PropertyInfo property = type.GetProperty( propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly ); ! if( property != null ) { ! return new BasicGetter( type, property, propertyName ); ! } ! else { BasicGetter getter = GetGetterOrNull( type.BaseType, propertyName ); ! if( getter == null ) { ! System.Type[ ] interfaces = type.GetInterfaces(); ! for( int i = 0; getter == null && i < interfaces.Length; i++ ) { ! getter = GetGetterOrNull( interfaces[ i ], propertyName ); } } *************** *** 82,85 **** } ! } ! } --- 118,121 ---- } ! } ! } \ No newline at end of file Index: BasicGetter.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/BasicGetter.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BasicGetter.cs 22 Aug 2004 06:18:54 -0000 1.1 --- BasicGetter.cs 31 Dec 2004 21:55:37 -0000 1.2 *************** *** 4,11 **** namespace NHibernate.Property { ! ! /// <summary> ! /// ! /// </summary> public sealed class BasicGetter : IGetter { --- 4,8 ---- namespace NHibernate.Property { ! /// <summary></summary> public sealed class BasicGetter : IGetter { *************** *** 14,18 **** private string propertyName; ! public BasicGetter(System.Type clazz, PropertyInfo property, string propertyName) { this.clazz = clazz; --- 11,21 ---- private string propertyName; ! /// <summary> ! /// ! /// </summary> ! /// <param name="clazz"></param> ! /// <param name="property"></param> ! /// <param name="propertyName"></param> ! public BasicGetter( System.Type clazz, PropertyInfo property, string propertyName ) { this.clazz = clazz; *************** *** 23,38 **** #region IGetter Members ! public object Get(object target) { ! try { ! return property.GetValue(target, new object[0]); ! } ! catch (Exception e) { ! throw new PropertyAccessException(e, "Exception occurred", false, clazz, propertyName); } } public System.Type ReturnType { --- 26,47 ---- #region IGetter Members ! /// <summary> ! /// ! /// </summary> ! /// <param name="target"></param> ! /// <returns></returns> ! public object Get( object target ) { ! try { ! return property.GetValue( target, new object[0] ); ! } ! catch( Exception e ) { ! throw new PropertyAccessException( e, "Exception occurred", false, clazz, propertyName ); } } + /// <summary></summary> public System.Type ReturnType { *************** *** 40,43 **** --- 49,53 ---- } + /// <summary></summary> public string PropertyName { *************** *** 45,54 **** } public PropertyInfo Property { ! get{ return property; } } #endregion } ! } --- 55,65 ---- } + /// <summary></summary> public PropertyInfo Property { ! get { return property; } } #endregion } ! } \ No newline at end of file Index: BasicSetter.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/BasicSetter.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BasicSetter.cs 22 Aug 2004 06:18:54 -0000 1.1 --- BasicSetter.cs 31 Dec 2004 21:55:38 -0000 1.2 *************** *** 4,10 **** namespace NHibernate.Property { ! /// <summary> ! /// ! /// </summary> public sealed class BasicSetter : ISetter { --- 4,8 ---- namespace NHibernate.Property { ! /// <summary></summary> public sealed class BasicSetter : ISetter { *************** *** 13,17 **** private string propertyName; ! public BasicSetter(System.Type clazz, PropertyInfo property, string propertyName) { this.clazz = clazz; --- 11,21 ---- private string propertyName; ! /// <summary> ! /// ! /// </summary> ! /// <param name="clazz"></param> ! /// <param name="property"></param> ! /// <param name="propertyName"></param> ! public BasicSetter( System.Type clazz, PropertyInfo property, string propertyName ) { this.clazz = clazz; *************** *** 22,37 **** #region ISetter Members ! public void Set(object target, object value) { ! try { ! property.SetValue(target, value, new object[0]); ! } ! catch (Exception e) { ! throw new PropertyAccessException(e, "Exception occurred", true, clazz, propertyName); } } public string PropertyName { --- 26,47 ---- #region ISetter Members ! /// <summary> ! /// ! /// </summary> ! /// <param name="target"></param> ! /// <param name="value"></param> ! public void Set( object target, object value ) { ! try { ! property.SetValue( target, value, new object[0] ); ! } ! catch( Exception e ) { ! throw new PropertyAccessException( e, "Exception occurred", true, clazz, propertyName ); } } + /// <summary></summary> public string PropertyName { *************** *** 39,42 **** --- 49,53 ---- } + /// <summary></summary> public PropertyInfo Property { *************** *** 46,48 **** #endregion } ! } --- 57,59 ---- #endregion } ! } \ No newline at end of file |