From: Michael D. <mik...@us...> - 2004-09-13 04:51:16
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23216/NHibernate/Util Modified Files: ReflectHelper.cs Log Message: Fixed NH-78 with Hql using const fields in classes. If the class is not a mapped class then it needs to be imported so NH can convert the class name to a fully qualified type name. Index: ReflectHelper.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Util/ReflectHelper.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ReflectHelper.cs 28 Aug 2004 04:57:15 -0000 1.14 --- ReflectHelper.cs 13 Sep 2004 04:51:05 -0000 1.15 *************** *** 77,95 **** } ! public static object GetConstantValue(string name) { ! System.Type clazz; ! try ! { ! clazz = ClassForName( StringHelper.Qualifier(name) ); ! } ! catch(Exception) ! { ! return null; ! } try { ! return clazz.GetProperty( StringHelper.Unqualify(name) ).GetValue(null, new object[0]); ! //?? } catch (Exception) --- 77,95 ---- } ! /// <summary> ! /// Returns the value contained in the static field. ! /// </summary> ! /// <param name="typeName">The name of the <see cref="System.Type"/>.</param> ! /// <param name="fieldName">The name of the Field in the <see cref="System.Type"/>.</param> ! /// <returns>The value contained in that field or <c>null</c> if the Type or Field does not exist.</returns> ! public static object GetConstantValue(string typeName, string fieldName) { ! System.Type clazz = System.Type.GetType( typeName, false ); ! ! if( clazz==null ) return null; ! try { ! return clazz.GetField( fieldName ).GetValue( null ); } catch (Exception) |