From: Kevin W. <kev...@us...> - 2004-12-31 17:56:00
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23023 Modified Files: OrExpression.cs PropertyExpression.cs SimpleExpression.cs SQLExpression.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: OrExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/OrExpression.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OrExpression.cs 28 Mar 2004 06:05:09 -0000 1.3 --- OrExpression.cs 31 Dec 2004 17:55:48 -0000 1.4 *************** *** 1,14 **** ! using System; ! ! namespace NHibernate.Expression { ! /// <summary> /// An Expression that combines two <see cref="Expression"/>s with an /// <c>"or"</c> between them. /// </summary> ! public class OrExpression : LogicalExpression { ! ! internal OrExpression(Expression lhs, Expression rhs) : base (lhs,rhs) { } --- 1,16 ---- ! namespace NHibernate.Expression ! { /// <summary> /// An Expression that combines two <see cref="Expression"/>s with an /// <c>"or"</c> between them. /// </summary> ! public class OrExpression : LogicalExpression { ! /// <summary> ! /// ! /// </summary> ! /// <param name="lhs"></param> ! /// <param name="rhs"></param> ! internal OrExpression( Expression lhs, Expression rhs ) : base( lhs, rhs ) { } *************** *** 18,25 **** /// </summary> /// <value>Returns "<c>or</c>"</value> ! protected override string Op { get { return "or"; } } } ! } --- 20,27 ---- /// </summary> /// <value>Returns "<c>or</c>"</value> ! protected override string Op { get { return "or"; } } } ! } \ No newline at end of file Index: SQLExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/SQLExpression.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SQLExpression.cs 26 Aug 2004 14:28:18 -0000 1.7 --- SQLExpression.cs 31 Dec 2004 17:55:48 -0000 1.8 *************** *** 1,10 **** - using System; - using NHibernate.Engine; using NHibernate.SqlCommand; using NHibernate.Type; - using NHibernate.Util; ! namespace NHibernate.Expression { /// <summary> --- 1,7 ---- using NHibernate.Engine; using NHibernate.SqlCommand; using NHibernate.Type; ! namespace NHibernate.Expression { /// <summary> *************** *** 17,50 **** public class SQLExpression : Expression { - private readonly SqlString sql; ! private readonly TypedValue[] typedValues; ! internal SQLExpression(SqlString sql, object[] values, IType[] types) { this.sql = sql; typedValues = new TypedValue[values.Length]; ! for ( int i=0; i<typedValues.Length; i++ ) { ! typedValues[i] = new TypedValue( types[i], values[i] ); } } ! ! public override SqlString ToSqlString(ISessionFactoryImplementor factory, System.Type persistentClass, string alias) { return sql.Replace( "$alias", alias ); } ! public override TypedValue[] GetTypedValues(ISessionFactoryImplementor sessionFactory, System.Type persistentClass) { return typedValues; } ! public override string ToString() { return sql.ToString(); } } ! } ! --- 14,64 ---- public class SQLExpression : Expression { private readonly SqlString sql; ! private readonly TypedValue[ ] typedValues; ! /// <summary> ! /// ! /// </summary> ! /// <param name="sql"></param> ! /// <param name="values"></param> ! /// <param name="types"></param> ! internal SQLExpression( SqlString sql, object[ ] values, IType[ ] types ) { this.sql = sql; typedValues = new TypedValue[values.Length]; ! for( int i = 0; i < typedValues.Length; i++ ) { ! typedValues[ i ] = new TypedValue( types[ i ], values[ i ] ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="factory"></param> ! /// <param name="persistentClass"></param> ! /// <param name="alias"></param> ! /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { return sql.Replace( "$alias", alias ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sessionFactory"></param> ! /// <param name="persistentClass"></param> ! /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { return typedValues; } ! /// <summary></summary> ! public override string ToString() { return sql.ToString(); } } ! } \ No newline at end of file Index: SimpleExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/SimpleExpression.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SimpleExpression.cs 28 Mar 2004 06:05:09 -0000 1.5 --- SimpleExpression.cs 31 Dec 2004 17:55:48 -0000 1.6 *************** *** 1,12 **** - using System; - using System.Text; - using NHibernate.Engine; using NHibernate.Persister; using NHibernate.SqlCommand; using NHibernate.Type; - using NHibernate.Util; ! namespace NHibernate.Expression { /// <summary> --- 1,8 ---- using NHibernate.Engine; using NHibernate.Persister; using NHibernate.SqlCommand; using NHibernate.Type; ! namespace NHibernate.Expression { /// <summary> *************** *** 14,20 **** /// to a value. /// </summary> ! public abstract class SimpleExpression : Expression { - private readonly string propertyName; --- 10,15 ---- /// to a value. /// </summary> ! public abstract class SimpleExpression : Expression { private readonly string propertyName; *************** *** 27,31 **** /// <param name="propertyName">The name of the Property in the class.</param> /// <param name="expressionValue">The value for the Property.</param> ! internal SimpleExpression(string propertyName, object expressionValue) { this.propertyName = propertyName; --- 22,26 ---- /// <param name="propertyName">The name of the Property in the class.</param> /// <param name="expressionValue">The value for the Property.</param> ! internal SimpleExpression( string propertyName, object expressionValue ) { this.propertyName = propertyName; *************** *** 37,43 **** /// </summary> /// <value>A string that is the name of the Property.</value> ! public string PropertyName { ! get {return propertyName;} } --- 32,38 ---- /// </summary> /// <value>A string that is the name of the Property.</value> ! public string PropertyName { ! get { return propertyName; } } *************** *** 46,52 **** /// </summary> /// <value>An object that is the value for the Expression.</value> ! public object Value { ! get {return expressionValue;} } --- 41,47 ---- /// </summary> /// <value>An object that is the value for the Expression.</value> ! public object Value { ! get { return expressionValue; } } *************** *** 58,80 **** /// <param name="alias">The alias to use for the table.</param> /// <returns>A SqlString that contains a valid Sql fragment.</returns> ! public override SqlString ToSqlString(ISessionFactoryImplementor factory, System.Type persistentClass, string alias) { - //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ((IQueryable)factory.GetPersister(persistentClass)).GetPropertyType(propertyName); ! string[] columnNames = GetColumns(factory, persistentClass, propertyName, alias); ! string[] paramColumnNames = GetColumns(factory, persistentClass, propertyName , null); ! Parameter[] parameters = Parameter.GenerateParameters(factory, alias, paramColumnNames, propertyType); ! ! for(int i = 0; i < columnNames.Length; i++) { ! if(i > 0) sqlBuilder.Add(" AND "); ! ! sqlBuilder.Add(columnNames[i]) ! .Add(Op) ! .Add(parameters[i]); } --- 53,77 ---- /// <param name="alias">The alias to use for the table.</param> /// <returns>A SqlString that contains a valid Sql fragment.</returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) { //TODO: add default capacity SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! IType propertyType = ( ( IQueryable ) factory.GetPersister( persistentClass ) ).GetPropertyType( propertyName ); ! string[ ] columnNames = GetColumns( factory, persistentClass, propertyName, alias ); ! string[ ] paramColumnNames = GetColumns( factory, persistentClass, propertyName, null ); ! Parameter[ ] parameters = Parameter.GenerateParameters( factory, alias, paramColumnNames, propertyType ); ! ! for( int i = 0; i < columnNames.Length; i++ ) { ! if( i > 0 ) ! { ! sqlBuilder.Add( " AND " ); ! } ! ! sqlBuilder.Add( columnNames[ i ] ) ! .Add( Op ) ! .Add( parameters[ i ] ); } *************** *** 83,97 **** } ! ! public override TypedValue[] GetTypedValues(ISessionFactoryImplementor sessionFactory, System.Type persistentClass) { ! return new TypedValue[] { GetTypedValue(sessionFactory, persistentClass, propertyName, expressionValue) }; } ! public override string ToString() { return propertyName + Op + expressionValue; } protected abstract string Op { get; } //protected ??? } --- 80,101 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sessionFactory"></param> ! /// <param name="persistentClass"></param> ! /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) { ! return new TypedValue[ ] {GetTypedValue( sessionFactory, persistentClass, propertyName, expressionValue )}; } ! /// <summary></summary> ! public override string ToString() { return propertyName + Op + expressionValue; } + /// <summary></summary> protected abstract string Op { get; } //protected ??? } Index: PropertyExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/PropertyExpression.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PropertyExpression.cs 2 Aug 2004 04:30:37 -0000 1.1 --- PropertyExpression.cs 31 Dec 2004 17:55:48 -0000 1.2 *************** *** 1,63 **** - using System; - using NHibernate.Engine; using NHibernate.SqlCommand; - using NHibernate.Util; namespace NHibernate.Expression { ! /// <summary> ! /// Superclass for comparisons between two properties (with SQL binary operators) ! /// </summary> ! public abstract class PropertyExpression : Expression ! { ! private string propertyName; ! private string otherPropertyName; ! private static TypedValue[] NoTypedValues = new TypedValue[0]; ! protected PropertyExpression(string propertyName, string otherPropertyName) ! { ! this.propertyName = propertyName; ! this.otherPropertyName = otherPropertyName; ! } ! public override SqlString ToSqlString(ISessionFactoryImplementor factory, System.Type persistentClass, string alias) ! { ! SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! string[] columnNames = GetColumns(factory, persistentClass, propertyName, alias); ! string[] otherColumnNames = GetColumns(factory, persistentClass, otherPropertyName, alias); ! bool andNeeded = false; ! for (int i = 0; i < columnNames.Length; i++) ! { ! if (andNeeded) ! sqlBuilder.Add(" AND "); ! andNeeded = true; ! ! sqlBuilder.Add(columnNames[i]).Add(Op).Add(otherColumnNames[i]); ! } ! return sqlBuilder.ToSqlString(); ! //TODO: get SQL rendering out of this package! ! } ! public override TypedValue[] GetTypedValues(ISessionFactoryImplementor sessionFactory, System.Type persistentClass) ! { ! return NoTypedValues; ! } ! public override string ToString() ! { ! return propertyName + Op + otherPropertyName; ! } ! protected abstract string Op ! { ! get; ! } ! } } \ No newline at end of file --- 1,79 ---- using NHibernate.Engine; using NHibernate.SqlCommand; namespace NHibernate.Expression { ! /// <summary> ! /// Superclass for comparisons between two properties (with SQL binary operators) ! /// </summary> ! public abstract class PropertyExpression : Expression ! { ! private string propertyName; ! private string otherPropertyName; ! private static TypedValue[ ] NoTypedValues = new TypedValue[0]; ! /// <summary> ! /// ! /// </summary> ! /// <param name="propertyName"></param> ! /// <param name="otherPropertyName"></param> ! protected PropertyExpression( string propertyName, string otherPropertyName ) ! { ! this.propertyName = propertyName; ! this.otherPropertyName = otherPropertyName; ! } ! /// <summary> ! /// ! /// </summary> ! /// <param name="factory"></param> ! /// <param name="persistentClass"></param> ! /// <param name="alias"></param> ! /// <returns></returns> ! public override SqlString ToSqlString( ISessionFactoryImplementor factory, System.Type persistentClass, string alias ) ! { ! SqlStringBuilder sqlBuilder = new SqlStringBuilder(); ! string[ ] columnNames = GetColumns( factory, persistentClass, propertyName, alias ); ! string[ ] otherColumnNames = GetColumns( factory, persistentClass, otherPropertyName, alias ); ! bool andNeeded = false; ! for( int i = 0; i < columnNames.Length; i++ ) ! { ! if( andNeeded ) ! { ! sqlBuilder.Add( " AND " ); ! } ! andNeeded = true; ! sqlBuilder.Add( columnNames[ i ] ).Add( Op ).Add( otherColumnNames[ i ] ); ! } ! return sqlBuilder.ToSqlString(); ! //TODO: get SQL rendering out of this package! ! } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sessionFactory"></param> ! /// <param name="persistentClass"></param> ! /// <returns></returns> ! public override TypedValue[ ] GetTypedValues( ISessionFactoryImplementor sessionFactory, System.Type persistentClass ) ! { ! return NoTypedValues; ! } ! /// <summary></summary> ! public override string ToString() ! { ! return propertyName + Op + otherPropertyName; ! } ! ! /// <summary></summary> ! protected abstract string Op { get; } ! } } \ No newline at end of file |