From: Michael D. <mik...@us...> - 2004-10-23 15:01:31
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Property In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20833/NHibernate/Property Modified Files: FieldGetter.cs PropertyAccessorFactory.cs Log Message: NH-134 Index: FieldGetter.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/FieldGetter.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FieldGetter.cs 22 Aug 2004 06:18:54 -0000 1.1 --- FieldGetter.cs 23 Oct 2004 15:01:21 -0000 1.2 *************** *** 33,37 **** public System.Type ReturnType { ! get { return field.ReflectedType; } } --- 33,37 ---- public System.Type ReturnType { ! get { return field.FieldType; } } Index: PropertyAccessorFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Property/PropertyAccessorFactory.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PropertyAccessorFactory.cs 10 Sep 2004 21:23:15 -0000 1.4 --- PropertyAccessorFactory.cs 23 Oct 2004 15:01:21 -0000 1.5 *************** *** 1,3 **** --- 1,4 ---- using System; + using System.Collections; using System.Reflection; *************** *** 11,22 **** public class PropertyAccessorFactory { ! private static readonly IPropertyAccessor basicPropertyAccessor = new BasicPropertyAccessor(); ! private static readonly IPropertyAccessor fieldAccessor = new FieldAccessor(); ! private static readonly IPropertyAccessor fieldCamelCaseAccessor = new FieldAccessor( new CamelCaseStrategy() ); ! private static readonly IPropertyAccessor fieldCamelCaseUnderscoreAccessor = new FieldAccessor( new CamelCaseUnderscoreStrategy() ); ! private static readonly IPropertyAccessor fieldPascalCaseMUnderscoreAccessor = new FieldAccessor( new PascalCaseMUnderscoreStrategy() ); ! private static readonly IPropertyAccessor noSetterCamelCaseAccessor = new NoSetterAccessor( new CamelCaseStrategy() ); ! private static readonly IPropertyAccessor noSetterCamelCaseUnderscoreAccessor = new NoSetterAccessor( new CamelCaseUnderscoreStrategy() ); ! private static readonly IPropertyAccessor noSetterPascalCaseMUnderscoreAccessor = new NoSetterAccessor( new PascalCaseMUnderscoreStrategy() ); private PropertyAccessorFactory() --- 12,29 ---- public class PropertyAccessorFactory { ! 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["nosetter.camelcase"] = new NoSetterAccessor( new CamelCaseStrategy() ); ! accessors["nosetter.camelcase-underscore"] = new NoSetterAccessor( new CamelCaseUnderscoreStrategy() ); ! accessors["nosetter.pascalcase-m-underscore"] = new NoSetterAccessor( new PascalCaseMUnderscoreStrategy() ); ! } private PropertyAccessorFactory() *************** *** 26,33 **** /// <summary> ! /// Gets or creates the IPropertyAccessor specified by the type. /// </summary> /// <param name="type"></param> ! /// <returns></returns> /// <remarks> /// <para> --- 33,49 ---- /// <summary> ! /// Gets an <see cref="IDictionary"/> of the built in <see cref="IPropertyAccessor"/> strategies. ! /// </summary> ! /// <value>An <see cref="IDictionary"/> of the built in <see cref="IPropertyAccessor"/> strategies.</value> ! public static IDictionary PropertyAccessors ! { ! get { return accessors; } ! } ! ! /// <summary> ! /// Gets or creates the <see cref="IPropertyAccessor" /> specified by the type. /// </summary> /// <param name="type"></param> ! /// <returns>The <see cref="IPropertyAccessor"/> specified by the type.</returns> /// <remarks> /// <para> *************** *** 119,149 **** public static IPropertyAccessor GetPropertyAccessor(string type) { ! if( type==null || "property".Equals(type) ) return basicPropertyAccessor; ! ! switch(type) { ! case "field" : ! return fieldAccessor; ! ! case "field.camelcase" : ! return fieldCamelCaseAccessor; ! ! case "field.camelcase-underscore" : ! return fieldCamelCaseUnderscoreAccessor; ! ! case "field.pascalcase-m-underscore" : ! return fieldPascalCaseMUnderscoreAccessor; ! ! case "nosetter.camelcase" : ! return noSetterCamelCaseAccessor; ! ! case "nosetter.camelcase-underscore" : ! return noSetterCamelCaseUnderscoreAccessor; ! ! case "nosetter.pascalcase-m-underscore" : ! return noSetterPascalCaseMUnderscoreAccessor; } System.Type accessorClass; try --- 135,154 ---- 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"; ! } + // 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 |