Skip to content

Commit 9c54778

Browse files
committed
Fix NH-2551
SVN: trunk@5761
1 parent 4a8b374 commit 9c54778

File tree

2 files changed

+45
-29
lines changed

2 files changed

+45
-29
lines changed

src/NHibernate/Impl/SessionFactoryImpl.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ public string[] GetImplementors(string className)
613613
{
614614
try
615615
{
616-
clazz = ReflectHelper.ClassForFullName(className);
616+
clazz = ReflectHelper.ClassForFullNameOrNull(className);
617617
}
618618
catch (Exception)
619619
{

src/NHibernate/Util/ReflectHelper.cs

+44-28
Original file line numberDiff line numberDiff line change
@@ -192,37 +192,53 @@ public static System.Type ClassForName(string name)
192192
/// the method try to find the System.Type scanning all Assemblies of the <see cref="AppDomain.CurrentDomain"/>.
193193
/// </remarks>
194194
/// <exception cref="TypeLoadException">If no System.Type was found for <paramref name="classFullName"/>.</exception>
195-
public static System.Type ClassForFullName(string classFullName)
195+
public static System.Type ClassForFullName(string classFullName)
196196
{
197-
System.Type result = null;
198-
AssemblyQualifiedTypeName parsedName = TypeNameParser.Parse(classFullName);
199-
if (!string.IsNullOrEmpty(parsedName.Assembly))
200-
{
201-
result = TypeFromAssembly(parsedName, false);
202-
}
203-
else
204-
{
205-
if (!string.IsNullOrEmpty(classFullName))
206-
{
207-
Assembly[] ass = AppDomain.CurrentDomain.GetAssemblies();
208-
foreach (Assembly a in ass)
209-
{
210-
result = a.GetType(classFullName, false, false);
211-
if (result != null)
212-
break; //<<<<<================
213-
}
214-
}
215-
}
216-
if (result == null)
217-
{
218-
string message = "Could not load type " + classFullName + ". Possible cause: the assembly was not loaded or not specified.";
219-
throw new TypeLoadException(message);
220-
}
221-
222-
return result;
197+
var result = ClassForFullNameOrNull(classFullName);
198+
if (result == null)
199+
{
200+
string message = "Could not load type " + classFullName + ". Possible cause: the assembly was not loaded or not specified.";
201+
throw new TypeLoadException(message);
202+
}
203+
204+
return result;
223205
}
224206

225-
public static System.Type TypeFromAssembly(string type, string assembly, bool throwIfError)
207+
/// <summary>
208+
/// Load a System.Type given is't name.
209+
/// </summary>
210+
/// <param name="classFullName">The class FullName or AssemblyQualifiedName</param>
211+
/// <returns>The System.Type or null</returns>
212+
/// <remarks>
213+
/// If the <paramref name="classFullName"/> don't represent an <see cref="System.Type.AssemblyQualifiedName"/>
214+
/// the method try to find the System.Type scanning all Assemblies of the <see cref="AppDomain.CurrentDomain"/>.
215+
/// </remarks>
216+
public static System.Type ClassForFullNameOrNull(string classFullName)
217+
{
218+
System.Type result = null;
219+
AssemblyQualifiedTypeName parsedName = TypeNameParser.Parse(classFullName);
220+
if (!string.IsNullOrEmpty(parsedName.Assembly))
221+
{
222+
result = TypeFromAssembly(parsedName, false);
223+
}
224+
else
225+
{
226+
if (!string.IsNullOrEmpty(classFullName))
227+
{
228+
Assembly[] ass = AppDomain.CurrentDomain.GetAssemblies();
229+
foreach (Assembly a in ass)
230+
{
231+
result = a.GetType(classFullName, false, false);
232+
if (result != null)
233+
break; //<<<<<================
234+
}
235+
}
236+
}
237+
238+
return result;
239+
}
240+
241+
public static System.Type TypeFromAssembly(string type, string assembly, bool throwIfError)
226242
{
227243
return TypeFromAssembly(new AssemblyQualifiedTypeName(type, assembly), throwIfError);
228244
}

0 commit comments

Comments
 (0)