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 |