From: Michael D. <mik...@us...> - 2005-04-18 02:55:46
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18776/NHibernate/Expression Modified Files: Example.cs InExpression.cs InsensitiveLikeExpression.cs LeExpression.cs LePropertyExpression.cs LtExpression.cs LtPropertyExpression.cs MatchMode.cs Log Message: Finished up the QBE Tests. Index: InsensitiveLikeExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/InsensitiveLikeExpression.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** InsensitiveLikeExpression.cs 17 Apr 2005 17:16:05 -0000 1.5 --- InsensitiveLikeExpression.cs 18 Apr 2005 02:55:29 -0000 1.6 *************** *** 1,2 **** --- 1,3 ---- + using System; using System.Collections; using NHibernate.Dialect; Index: Example.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/Example.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Example.cs 17 Apr 2005 17:16:05 -0000 1.2 --- Example.cs 18 Apr 2005 02:55:28 -0000 1.3 *************** *** 1,7 **** using System; using System.Collections; - using Iesi.Collections; - using NHibernate.Engine; using NHibernate.Metadata; --- 1,5 ---- *************** *** 13,17 **** { /// <summary> ! /// Summary description for Example. /// </summary> public class Example : AbstractCriterion --- 11,15 ---- { /// <summary> ! /// Support for <c>Query By Example</c>. /// </summary> public class Example : AbstractCriterion *************** *** 22,45 **** private bool _isLikeEnabled; private MatchMode _matchMode; ! /// <summary> /// A strategy for choosing property values for inclusion in the query criteria /// </summary> ! public interface IPropertySelector { /// <summary> ! /// /// </summary> ! /// <param name="propertyValue"></param> ! /// <param name="propertyName"></param> ! /// <param name="type"></param> ! /// <returns></returns> bool Include(object propertyValue, String propertyName, IType type); } ! private static readonly IPropertySelector NotNullOrEmptyString = new NotNullOrEmptyStringPropertySelector(); private static readonly IPropertySelector All = new AllPropertySelector(); private static readonly IPropertySelector NotNullOrZero = new NotNullOrZeroPropertySelector(); ! private class AllPropertySelector : IPropertySelector { --- 20,50 ---- private bool _isLikeEnabled; private MatchMode _matchMode; ! /// <summary> /// A strategy for choosing property values for inclusion in the query criteria /// </summary> ! public interface IPropertySelector { /// <summary> ! /// Determine if the Property should be included. /// </summary> ! /// <param name="propertyValue">The value of the property that is being checked for inclusion.</param> ! /// <param name="propertyName">The name of the property that is being checked for inclusion.</param> ! /// <param name="type">The <see cref="IType"/> of the property.</param> ! /// <returns> ! /// <c>true</c> if the Property should be included in the Query, ! /// <c>false</c> otherwise. ! /// </returns> bool Include(object propertyValue, String propertyName, IType type); } ! private static readonly IPropertySelector NotNullOrEmptyString = new NotNullOrEmptyStringPropertySelector(); private static readonly IPropertySelector All = new AllPropertySelector(); private static readonly IPropertySelector NotNullOrZero = new NotNullOrZeroPropertySelector(); ! ! /// <summary> ! /// Implementation of <see cref="IPropertySelector"/> that includes all ! /// properties regardless of value. ! /// </summary> private class AllPropertySelector : IPropertySelector { *************** *** 49,67 **** } } ! internal class NotNullOrEmptyStringPropertySelector : IPropertySelector { - public bool Include(object propertyValue, String propertyName, IType type) { ! if(propertyValue != null) { ! if(propertyValue.ToString() != "") ! return true; ! else ! return false; } else return false; } --- 54,79 ---- } } ! ! /// <summary> ! /// Implementation of <see cref="IPropertySelector"/> that includes the ! /// properties that are not <c>null</c> and do not have an <see cref="String.Empty"/> ! /// returned by <c>propertyValue.ToString()</c>. ! /// </summary> internal class NotNullOrEmptyStringPropertySelector : IPropertySelector { public bool Include(object propertyValue, String propertyName, IType type) { ! if( propertyValue != null ) { ! // TODO: find out why we are checking ToString() - why is null ! // and not null not good enough??? ! // used to be propertyValue.ToString()!="" but that creates an ! // extra string in memory ! return ( propertyValue.ToString().Length > 0 ); } else + { return false; + } } *************** *** 69,129 **** } - /// <summary> /// This Can't work right now. Have to figure out some way to use Magic values /// to avoid the non-nullable types in .NET. /// </summary> ! internal class NotNullOrZeroPropertySelector : IPropertySelector { ! public bool Include(object propertyValue, String propertyName, IType type) ! { ! return propertyValue!=null ;/*&& (!char.IsNumber(propertyValue as char) || ( (int) propertyValue !=0));*/ } } ! /// <summary> ! /// Set the property selector /// </summary> ! public Example SetPropertySelector(IPropertySelector selector) { ! this._selector = selector; return this; } ! ! /// <summary> ! /// Exclude zero-valued properties /// </summary> ! public Example ExcludeNulls() { ! SetPropertySelector(NotNullOrEmptyString); return this; } ! /// <summary> ! /// Don't exclude null or zero-valued properties /// </summary> ! public Example ExcludeNone() { ! SetPropertySelector(All); return this; } ! /// <summary> ! /// Use the "like" operator for all string-valued properties /// </summary> ! public Example EnableLike(MatchMode matchMode) { _isLikeEnabled = true; ! this._matchMode = matchMode; return this; } ! /// <summary> ! /// Use the "like" operator for all string-valued properties /// </summary> ! public Example EnableLike() { ! return EnableLike(MatchMode.Exact); } --- 81,157 ---- } /// <summary> /// This Can't work right now. Have to figure out some way to use Magic values /// to avoid the non-nullable types in .NET. /// </summary> ! internal class NotNullOrZeroPropertySelector : IPropertySelector { ! public bool Include(object propertyValue, String propertyName, IType type) ! { ! return propertyValue != null; /*&& (!char.IsNumber(propertyValue as char) || ( (int) propertyValue !=0));*/ } } ! /// <summary> ! /// Set the <see cref="IPropertySelector"/> for this <see cref="Example"/>. /// </summary> ! /// <param name="selector">The <see cref="IPropertySelector"/> to determine which properties to include.</param> ! /// <returns>This <see cref="Example"/> instance.</returns> ! /// <remarks> ! /// This should be used when a custom <see cref="IPropertySelector"/> has ! /// been implemented. Otherwise use the methods <see cref="Example.ExcludeNulls"/> ! /// or <see cref="Example.ExcludeNone"/> to set the <see cref="IPropertySelector"/> ! /// to the <see cref="IPropertySelector"/>s built into NHibernate. ! /// </remarks> ! public Example SetPropertySelector(IPropertySelector selector) { ! _selector = selector; return this; } ! /// <summary> ! /// Set the <see cref="IPropertySelector"/> for this <see cref="Example"/> ! /// to exclude zero-valued properties. /// </summary> ! public Example ExcludeNulls() { ! SetPropertySelector( NotNullOrEmptyString ); return this; } ! /// <summary> ! /// Set the <see cref="IPropertySelector"/> for this <see cref="Example"/> ! /// to exclude no properties. /// </summary> ! public Example ExcludeNone() { ! SetPropertySelector( All ); return this; } ! /// <summary> ! /// Use the "like" operator for all string-valued properties with ! /// the specified <see cref="MatchMode"/>. /// </summary> ! /// <param name="matchMode"> ! /// The <see cref="MatchMode"/> to convert the string to the pattern ! /// for the <c>like</c> comparison. ! /// </param> ! public Example EnableLike(MatchMode matchMode) { _isLikeEnabled = true; ! _matchMode = matchMode; return this; } ! /// <summary> ! /// Use the "like" operator for all string-valued properties. /// </summary> ! /// <remarks> ! /// The default <see cref="MatchMode"/> is <see cref="MatchMode.Exact">MatchMode.Exact</see>. ! /// </remarks> ! public Example EnableLike() { ! return EnableLike( MatchMode.Exact ); } *************** *** 131,137 **** /// Exclude a particular named property /// </summary> ! public Example ExcludeProperty(String name) { ! _excludedProperties.Add(name); return this; } --- 159,166 ---- /// Exclude a particular named property /// </summary> ! /// <param name="name">The name of the property to exclude.</param> ! public Example ExcludeProperty(String name) { ! _excludedProperties.Add( name ); return this; } *************** *** 142,158 **** /// </summary> /// <param name="entity"></param> ! /// <returns>a new instance of <code>Example</code></returns> ! public static Example Create(object entity) { ! if (entity==null) throw new ArgumentException("null example"); ! return new Example(entity, NotNullOrEmptyString); } /// <summary> ! /// /// </summary> ! /// <param name="entity"></param> ! /// <param name="selector"></param> ! protected Example(object entity, IPropertySelector selector) { _entity = entity; --- 171,191 ---- /// </summary> /// <param name="entity"></param> ! /// <returns>A new instance of <see cref="Example" />.</returns> ! public static Example Create(object entity) { ! if( entity == null ) ! { ! throw new ArgumentException( "null example" ); ! } ! return new Example( entity, NotNullOrEmptyString ); } /// <summary> ! /// Initialize a new instance of the <see cref="Example" /> class for a particular ! /// entity. /// </summary> ! /// <param name="entity">The <see cref="Object"/> that the Example is being built from.</param> ! /// <param name="selector">The <see cref="IPropertySelector"/> the Example should use.</param> ! protected Example(object entity, IPropertySelector selector) { _entity = entity; *************** *** 160,177 **** } ! /// <summary> ! /// ! /// </summary> ! /// <returns></returns> ! public override String ToString() { return _entity.ToString(); } ! ! private bool IsPropertyIncluded(object value, String name, IType type) { ! return !_excludedProperties.Contains(name) && !type.IsAssociationType && ! _selector.Include(value, name, type); } --- 193,221 ---- } ! #region System.Object Members ! ! public override String ToString() { return _entity.ToString(); } ! ! #endregion ! ! ! /// <summary> ! /// Determines if the property should be included in the Query. ! /// </summary> ! /// <param name="value">The value of the property.</param> ! /// <param name="name">The name of the property.</param> ! /// <param name="type">The <see cref="IType"/> of the property.</param> ! /// <returns> ! /// <c>true</c> if the Property should be included, <c>false</c> if ! /// the Property should not be a part of the Query. ! /// </returns> ! private bool IsPropertyIncluded(object value, String name, IType type) { ! return !_excludedProperties.Contains( name ) && !type.IsAssociationType && ! _selector.Include( value, name, type ); } *************** *** 190,194 **** ArrayList list = new ArrayList(); ! for( int i=0; i<propertyNames.Length; i++) { object value = values[ i ]; --- 234,238 ---- ArrayList list = new ArrayList(); ! for( int i = 0; i < propertyNames.Length; i++ ) { object value = values[ i ]; *************** *** 196,200 **** string name = propertyNames[ i ]; ! bool isPropertyIncluded = ( i!=meta.VersionProperty && IsPropertyIncluded( value, name, type ) ); if( isPropertyIncluded ) --- 240,244 ---- string name = propertyNames[ i ]; ! bool isPropertyIncluded = ( i != meta.VersionProperty && IsPropertyIncluded( value, name, type ) ); if( isPropertyIncluded ) *************** *** 202,206 **** if( propertyTypes[ i ].IsComponentType ) { ! AddComponentTypedValues( name, value, (IAbstractComponentType)type, list ); } else --- 246,250 ---- if( propertyTypes[ i ].IsComponentType ) { ! AddComponentTypedValues( name, value, (IAbstractComponentType)type, list ); } else *************** *** 211,215 **** } ! return ( TypedValue[ ] ) list.ToArray( typeof( TypedValue ) ); } --- 255,259 ---- } ! return (TypedValue[])list.ToArray( typeof( TypedValue ) ); } *************** *** 226,249 **** builder.Add( StringHelper.OpenParen ); ! IClassMetadata meta = factory.GetClassMetadata(persistentClass); String[] propertyNames = meta.PropertyNames; IType[] propertyTypes = meta.PropertyTypes; ! object[] propertyValues = meta.GetPropertyValues(_entity); ! for (int i=0; i<propertyNames.Length; i++) { ! object propertyValue = propertyValues[i]; ! String propertyName = propertyNames[i]; ! // Have to figure out how to get the name or index of the version property ! bool isPropertyIncluded = i!=meta.VersionProperty && ! IsPropertyIncluded( propertyValue, propertyName, propertyTypes[i] ); ! if (isPropertyIncluded) { ! if ( propertyTypes[i].IsComponentType) { AppendComponentCondition( ! propertyName, ! propertyValue, ! (IAbstractComponentType) propertyTypes[i], persistentClass, alias, --- 270,293 ---- builder.Add( StringHelper.OpenParen ); ! IClassMetadata meta = factory.GetClassMetadata( persistentClass ); String[] propertyNames = meta.PropertyNames; IType[] propertyTypes = meta.PropertyTypes; ! object[] propertyValues = meta.GetPropertyValues( _entity ); ! for( int i = 0; i < propertyNames.Length; i++ ) { ! object propertyValue = propertyValues[ i ]; ! String propertyName = propertyNames[ i ]; ! // Have to figure out how to get the name or index of the version property ! bool isPropertyIncluded = i != meta.VersionProperty && ! IsPropertyIncluded( propertyValue, propertyName, propertyTypes[ i ] ); ! if( isPropertyIncluded ) { ! if( propertyTypes[ i ].IsComponentType ) { AppendComponentCondition( ! propertyName, ! propertyValue, ! (IAbstractComponentType)propertyTypes[ i ], persistentClass, alias, *************** *** 253,261 **** ); } ! else { AppendPropertyCondition( ! propertyName, ! propertyValue, persistentClass, alias, --- 297,305 ---- ); } ! else { AppendPropertyCondition( ! propertyName, ! propertyValue, persistentClass, alias, *************** *** 267,271 **** } } ! if( builder.Count==1 ) { builder.Add( "1=1" ); // yuck! --- 311,315 ---- } } ! if( builder.Count == 1 ) { builder.Add( "1=1" ); // yuck! *************** *** 275,279 **** return builder.ToSqlString(); } ! /// <summary> /// Adds a <see cref="TypedValue"/> based on the <c>value</c> --- 319,323 ---- return builder.ToSqlString(); } ! /// <summary> /// Adds a <see cref="TypedValue"/> based on the <c>value</c> *************** *** 284,287 **** --- 328,334 ---- /// <param name="type">The <see cref="IType"/> of the Property.</param> /// <param name="list">The <see cref="IList"/> to add the <see cref="TypedValue"/> to.</param> + /// <remarks> + /// This method will add <see cref="TypedValue"/> objects to the <c>list</c> parameter. + /// </remarks> protected void AddPropertyTypedValue(object value, IType type, IList list) { *************** *** 289,303 **** // or an ICollection that can be added to the list instead of modifying the // parameter passed in. ! if( value!=null ) { ! // TODO: h2.1 SYNCH: some code in here to check for ! // IsIgnoreCaseEnabled and IsLikeEnabled ! // string stringValue = value as string; ! // if( stringValue!=null ) ! // { ! // // ! // // ! // } ! list.Add( new TypedValue( type, value ) ); } --- 336,351 ---- // or an ICollection that can be added to the list instead of modifying the // parameter passed in. ! if( value != null ) { ! if( value is string ) ! { ! string stringValue = (string)value; ! // TODO: h2.1 SYNCH: some code in here to check for _isIgnoreCaseEnabled ! if( _isLikeEnabled ) ! { ! stringValue = _matchMode.ToMatchString( stringValue ); ! } ! value = stringValue; ! } list.Add( new TypedValue( type, value ) ); } *************** *** 306,320 **** protected void AddComponentTypedValues(string path, object component, IAbstractComponentType type, IList list) { ! //TODO: h2.1 SYNCH: resume here once IAbstractComponentType is fixed up. ! if( component!=null ) { string[] propertyNames = type.PropertyNames; IType[] subtypes = type.Subtypes; object[] values = type.GetPropertyValues( component ); ! for( int i=0; i<propertyNames.Length; i++ ) { ! object value = values[i]; ! IType subtype = subtypes[i]; ! string subpath = StringHelper.Qualify( path, propertyNames[i] ); if( IsPropertyIncluded( value, subpath, subtype ) ) { --- 354,367 ---- protected void AddComponentTypedValues(string path, object component, IAbstractComponentType type, IList list) { ! if( component != null ) { string[] propertyNames = type.PropertyNames; IType[] subtypes = type.Subtypes; object[] values = type.GetPropertyValues( component ); ! for( int i = 0; i < propertyNames.Length; i++ ) { ! object value = values[ i ]; ! IType subtype = subtypes[ i ]; ! string subpath = StringHelper.Qualify( path, propertyNames[ i ] ); if( IsPropertyIncluded( value, subpath, subtype ) ) { *************** *** 332,335 **** --- 379,383 ---- } } + /// <summary> /// *************** *** 341,353 **** /// <param name="sessionFactory"></param> protected void AppendPropertyCondition( ! String propertyName, ! object propertyValue, System.Type persistentClass, String alias, IDictionary aliasClasses, ISessionFactoryImplementor sessionFactory, ! SqlStringBuilder builder) { ! if( builder.Count>1 ) { builder.Add( " and " ); --- 389,401 ---- /// <param name="sessionFactory"></param> protected void AppendPropertyCondition( ! String propertyName, ! object propertyValue, System.Type persistentClass, String alias, IDictionary aliasClasses, ISessionFactoryImplementor sessionFactory, ! SqlStringBuilder builder) { ! if( builder.Count > 1 ) { builder.Add( " and " ); *************** *** 355,373 **** ICriterion crit; ! if ( propertyValue!=null ) { bool isString = propertyValue is String; crit = ( _isLikeEnabled && isString ) ? ! (ICriterion) new LikeExpression( propertyName, propertyValue) : ! (ICriterion) new EqExpression( propertyName, propertyValue ); ! } ! else { ! crit = new NullExpression(propertyName); } builder.Add( crit.ToSqlString( sessionFactory, persistentClass, alias, aliasClasses ) ); } ! /// <summary> /// --- 403,421 ---- ICriterion crit; ! if( propertyValue != null ) { bool isString = propertyValue is String; crit = ( _isLikeEnabled && isString ) ? ! (ICriterion)new LikeExpression( propertyName, propertyValue ) : ! (ICriterion)new EqExpression( propertyName, propertyValue ); ! } ! else { ! crit = new NullExpression( propertyName ); } builder.Add( crit.ToSqlString( sessionFactory, persistentClass, alias, aliasClasses ) ); } ! /// <summary> /// *************** *** 380,411 **** /// <param name="sessionFactory"></param> protected void AppendComponentCondition( ! String path, ! object component, ! IAbstractComponentType type, System.Type persistentClass, String alias, IDictionary aliasClasses, ISessionFactoryImplementor sessionFactory, ! SqlStringBuilder builder) { ! ! if (component!=null) { String[] propertyNames = type.PropertyNames; ! object[] values = type.GetPropertyValues(component, null); IType[] subtypes = type.Subtypes; ! for (int i=0; i<propertyNames.Length; i++) { ! String subpath = StringHelper.Qualify( path, propertyNames[i] ); ! object value = values[i]; ! if ( IsPropertyIncluded( value, subpath, subtypes[i] ) ) { ! IType subtype = subtypes[i]; ! if ( subtype.IsComponentType ) { AppendComponentCondition( subpath, value, ! (IAbstractComponentType) subtype, persistentClass, alias, --- 428,458 ---- /// <param name="sessionFactory"></param> protected void AppendComponentCondition( ! String path, ! object component, ! IAbstractComponentType type, System.Type persistentClass, String alias, IDictionary aliasClasses, ISessionFactoryImplementor sessionFactory, ! SqlStringBuilder builder) { ! if( component != null ) { String[] propertyNames = type.PropertyNames; ! object[] values = type.GetPropertyValues( component, null ); IType[] subtypes = type.Subtypes; ! for( int i = 0; i < propertyNames.Length; i++ ) { ! String subpath = StringHelper.Qualify( path, propertyNames[ i ] ); ! object value = values[ i ]; ! if( IsPropertyIncluded( value, subpath, subtypes[ i ] ) ) { ! IType subtype = subtypes[ i ]; ! if( subtype.IsComponentType ) { AppendComponentCondition( subpath, value, ! (IAbstractComponentType)subtype, persistentClass, alias, *************** *** 413,425 **** sessionFactory, builder ); ! } ! else { ! AppendPropertyCondition( subpath, ! value, persistentClass, alias, ! aliasClasses, sessionFactory, builder --- 460,472 ---- sessionFactory, builder ); ! } ! else { ! AppendPropertyCondition( subpath, ! value, persistentClass, alias, ! aliasClasses, sessionFactory, builder *************** *** 431,433 **** } } ! } --- 478,480 ---- } } ! } \ No newline at end of file Index: LtPropertyExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/LtPropertyExpression.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LtPropertyExpression.cs 17 Apr 2005 17:16:05 -0000 1.3 --- LtPropertyExpression.cs 18 Apr 2005 02:55:29 -0000 1.4 *************** *** 1,2 **** --- 1,4 ---- + using System; + namespace NHibernate.Expression { Index: InExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/InExpression.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** InExpression.cs 17 Apr 2005 17:16:05 -0000 1.6 --- InExpression.cs 18 Apr 2005 02:55:29 -0000 1.7 *************** *** 1,2 **** --- 1,3 ---- + using System; using System.Collections; using NHibernate.Engine; Index: MatchMode.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/MatchMode.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MatchMode.cs 17 Apr 2005 17:16:05 -0000 1.2 --- MatchMode.cs 18 Apr 2005 02:55:29 -0000 1.3 *************** *** 4,8 **** namespace NHibernate.Expression { - // TODO: find where this is used and test/fix it up /// <summary> /// Represents an strategy for matching strings using "like". --- 4,7 ---- *************** *** 14,32 **** private static Hashtable Instances = new Hashtable(); /// <summary> ! /// /// </summary> ! /// <param name="intCode"></param> ! /// <param name="name"></param> protected MatchMode(int intCode, string name) { ! this._intCode = intCode; ! this._name = name; } /// <summary> ! /// /// </summary> ! /// <returns></returns> public override string ToString() { --- 13,46 ---- private static Hashtable Instances = new Hashtable(); + static MatchMode() + { + Instances.Add( MatchMode.Exact._intCode, MatchMode.Exact ); + Instances.Add( MatchMode.Start._intCode, MatchMode.Start ); + Instances.Add( MatchMode.End._intCode, MatchMode.End ); + Instances.Add( MatchMode.Anywhere._intCode, MatchMode.Anywhere ); + } + /// <summary> ! /// Initialize a new instance of the <see cref="MatchMode" /> class. /// </summary> ! /// <param name="intCode">The code that identifies the match mode.</param> ! /// <param name="name">The friendly name of the match mode.</param> ! /// <remarks> ! /// The parameter <c>intCode</c> is used as the key of <see cref="IDictionary"/> ! /// to store instances and to ensure only instance of a particular <see cref="MatchMode"/> ! /// is created. ! /// </remarks> protected MatchMode(int intCode, string name) { ! _intCode = intCode; ! _name = name; } + #region System.Object Members + /// <summary> ! /// The string representation of the <see cref="MatchMode"/>. /// </summary> ! /// <returns>The friendly name used to describe the <see cref="MatchMode"/>.</returns> public override string ToString() { *************** *** 34,40 **** } /// <summary> ! /// convert the pattern, by appending/prepending "%" /// </summary> public abstract string ToMatchString(string pattern); --- 48,61 ---- } + #endregion + /// <summary> ! /// Convert the pattern, by appending/prepending "%" /// </summary> + /// <param name="pattern">The string to convert to the appropriate match pattern.</param> + /// <returns> + /// A <see cref="String"/> that contains a "%" in the appropriate place + /// for the Match Strategy. + /// </returns> public abstract string ToMatchString(string pattern); *************** *** 46,57 **** // } - static MatchMode() - { - Instances.Add( Exact._intCode, Exact ); - Instances.Add( Start._intCode, Start ); - Instances.Add( End._intCode, End ); - Instances.Add( Anywhere._intCode, Anywhere ); - } - /// <summary> /// Match the entire string to the pattern --- 67,70 ---- *************** *** 74,83 **** --- 87,108 ---- public static readonly MatchMode Anywhere = new AnywhereMatchMode(); + /// <summary> + /// The <see cref="MatchMode"/> that exactly matches the entire + /// string to the pattern. + /// </summary> private class ExactMatchMode : MatchMode { + /// <summary> + /// Initialize a new instance of the <see cref="ExactMatchMode" /> class. + /// </summary> public ExactMatchMode() : base( 0, "EXACT" ) { } + /// <summary> + /// Converts the string to the Exact MatchMode. + /// </summary> + /// <param name="pattern">The string to convert to the appropriate match pattern.</param> + /// <returns>The <c>pattern</c> exactly the same as it was passed in.</returns> public override string ToMatchString(string pattern) { *************** *** 86,95 **** --- 111,132 ---- } + /// <summary> + /// The <see cref="MatchMode"/> that exactly matches the string + /// by appending "<c>%</c>" to the beginning. + /// </summary> private class StartMatchMode : MatchMode { + /// <summary> + /// Initialize a new instance of the <see cref="StartMatchMode" /> class. + /// </summary> public StartMatchMode() : base( 1, "START" ) { } + /// <summary> + /// Converts the string to the Start MatchMode. + /// </summary> + /// <param name="pattern">The string to convert to the appropriate match pattern.</param> + /// <returns>The <c>pattern</c> with a "<c>%</c>" appended at the beginning.</returns> public override string ToMatchString(string pattern) { *************** *** 98,107 **** --- 135,156 ---- } + /// <summary> + /// The <see cref="MatchMode"/> that exactly matches the string + /// by appending "<c>%</c>" to the end. + /// </summary> private class EndMatchMode : MatchMode { + /// <summary> + /// Initialize a new instance of the <see cref="EndMatchMode" /> class. + /// </summary> public EndMatchMode() : base( 2, "END" ) { } + /// <summary> + /// Converts the string to the End MatchMode. + /// </summary> + /// <param name="pattern">The string to convert to the appropriate match pattern.</param> + /// <returns>The <c>pattern</c> with a "<c>%</c>" appended at the end.</returns> public override string ToMatchString(string pattern) { *************** *** 111,120 **** --- 160,181 ---- } + /// <summary> + /// The <see cref="MatchMode"/> that exactly matches the string + /// by appending "<c>%</c>" to the beginning and end. + /// </summary> private class AnywhereMatchMode : MatchMode { + /// <summary> + /// Initialize a new instance of the <see cref="AnywhereMatchMode" /> class. + /// </summary> public AnywhereMatchMode() : base( 3, "ANYWHERE" ) { } + /// <summary> + /// Converts the string to the Exact MatchMode. + /// </summary> + /// <param name="pattern">The string to convert to the appropriate match pattern.</param> + /// <returns>The <c>pattern</c> with a "<c>%</c>" appended at the beginning and the end.</returns> public override string ToMatchString(string pattern) { Index: LePropertyExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/LePropertyExpression.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LePropertyExpression.cs 17 Apr 2005 17:16:05 -0000 1.3 --- LePropertyExpression.cs 18 Apr 2005 02:55:29 -0000 1.4 *************** *** 1,2 **** --- 1,4 ---- + using System; + namespace NHibernate.Expression { Index: LtExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/LtExpression.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LtExpression.cs 17 Apr 2005 17:16:05 -0000 1.4 --- LtExpression.cs 18 Apr 2005 02:55:29 -0000 1.5 *************** *** 1,2 **** --- 1,4 ---- + using System; + namespace NHibernate.Expression { Index: LeExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/LeExpression.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LeExpression.cs 17 Apr 2005 17:16:05 -0000 1.5 --- LeExpression.cs 18 Apr 2005 02:55:29 -0000 1.6 *************** *** 1,2 **** --- 1,4 ---- + using System; + namespace NHibernate.Expression { |