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 |