|
From: <fab...@us...> - 2011-04-25 13:48:38
|
Revision: 5761
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5761&view=rev
Author: fabiomaulo
Date: 2011-04-25 13:48:32 +0000 (Mon, 25 Apr 2011)
Log Message:
-----------
Fix NH-2551
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs
trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs
Modified: trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2011-04-25 12:15:29 UTC (rev 5760)
+++ trunk/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs 2011-04-25 13:48:32 UTC (rev 5761)
@@ -613,7 +613,7 @@
{
try
{
- clazz = ReflectHelper.ClassForFullName(className);
+ clazz = ReflectHelper.ClassForFullNameOrNull(className);
}
catch (Exception)
{
Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2011-04-25 12:15:29 UTC (rev 5760)
+++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2011-04-25 13:48:32 UTC (rev 5761)
@@ -192,37 +192,53 @@
/// the method try to find the System.Type scanning all Assemblies of the <see cref="AppDomain.CurrentDomain"/>.
/// </remarks>
/// <exception cref="TypeLoadException">If no System.Type was found for <paramref name="classFullName"/>.</exception>
- public static System.Type ClassForFullName(string classFullName)
+ public static System.Type ClassForFullName(string classFullName)
{
- System.Type result = null;
- AssemblyQualifiedTypeName parsedName = TypeNameParser.Parse(classFullName);
- if (!string.IsNullOrEmpty(parsedName.Assembly))
- {
- result = TypeFromAssembly(parsedName, false);
- }
- else
- {
- if (!string.IsNullOrEmpty(classFullName))
- {
- Assembly[] ass = AppDomain.CurrentDomain.GetAssemblies();
- foreach (Assembly a in ass)
- {
- result = a.GetType(classFullName, false, false);
- if (result != null)
- break; //<<<<<================
- }
- }
- }
- if (result == null)
- {
- string message = "Could not load type " + classFullName + ". Possible cause: the assembly was not loaded or not specified.";
- throw new TypeLoadException(message);
- }
+ var result = ClassForFullNameOrNull(classFullName);
+ if (result == null)
+ {
+ string message = "Could not load type " + classFullName + ". Possible cause: the assembly was not loaded or not specified.";
+ throw new TypeLoadException(message);
+ }
- return result;
+ return result;
}
- public static System.Type TypeFromAssembly(string type, string assembly, bool throwIfError)
+ /// <summary>
+ /// Load a System.Type given is't name.
+ /// </summary>
+ /// <param name="classFullName">The class FullName or AssemblyQualifiedName</param>
+ /// <returns>The System.Type or null</returns>
+ /// <remarks>
+ /// If the <paramref name="classFullName"/> don't represent an <see cref="System.Type.AssemblyQualifiedName"/>
+ /// the method try to find the System.Type scanning all Assemblies of the <see cref="AppDomain.CurrentDomain"/>.
+ /// </remarks>
+ public static System.Type ClassForFullNameOrNull(string classFullName)
+ {
+ System.Type result = null;
+ AssemblyQualifiedTypeName parsedName = TypeNameParser.Parse(classFullName);
+ if (!string.IsNullOrEmpty(parsedName.Assembly))
+ {
+ result = TypeFromAssembly(parsedName, false);
+ }
+ else
+ {
+ if (!string.IsNullOrEmpty(classFullName))
+ {
+ Assembly[] ass = AppDomain.CurrentDomain.GetAssemblies();
+ foreach (Assembly a in ass)
+ {
+ result = a.GetType(classFullName, false, false);
+ if (result != null)
+ break; //<<<<<================
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public static System.Type TypeFromAssembly(string type, string assembly, bool throwIfError)
{
return TypeFromAssembly(new AssemblyQualifiedTypeName(type, assembly), throwIfError);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|