@@ -535,7 +535,16 @@ public static IType HeuristicType(string typeName)
535
535
/// </remarks>
536
536
public static IType HeuristicType ( System . Type type )
537
537
{
538
- return HeuristicType ( type , parameters : null , length : null ) ;
538
+ // Use the basic name (such as String) to get the instance of the IType object.
539
+ if ( typeByTypeOfName . TryGetValue ( type . AssemblyQualifiedName , out var returnType ) )
540
+ {
541
+ if ( _obsoleteMessageByAlias . TryGetValue ( type . AssemblyQualifiedName , out string obsoleteMessage ) )
542
+ _log . Warn ( "{0} is obsolete. {1}" , type . AssemblyQualifiedName , obsoleteMessage ) ;
543
+
544
+ return returnType ;
545
+ }
546
+
547
+ return GetNHibernateTypeFromSystemType ( type , null , null ) ;
539
548
}
540
549
541
550
/// <summary>
@@ -586,18 +595,12 @@ public static IType HeuristicType(string typeName, IDictionary<string, string> p
586
595
{
587
596
throw new MappingException ( "Could not find IType for given" + typeName + ": " + ex , ex ) ;
588
597
}
589
- return HeuristicType ( typeClass , parameters , length , false ) ;
598
+
599
+ return GetNHibernateTypeFromSystemType ( typeClass , parameters , length ) ;
590
600
}
591
601
592
- private static IType HeuristicType ( System . Type typeClass , IDictionary < string , string > parameters , int ? length , bool tryBasic = true )
602
+ private static IType GetNHibernateTypeFromSystemType ( System . Type typeClass , IDictionary < string , string > parameters , int ? length )
593
603
{
594
- if ( tryBasic )
595
- {
596
- IType type = Basic ( typeClass . AssemblyQualifiedName , parameters ) ;
597
-
598
- if ( type != null )
599
- return type ;
600
- }
601
604
if ( typeof ( IType ) . IsAssignableFrom ( typeClass ) )
602
605
{
603
606
try
@@ -610,6 +613,7 @@ private static IType HeuristicType(System.Type typeClass, IDictionary<string, st
610
613
{
611
614
_log . Warn ( "{0} is obsolete. {1}" , typeClass . AssemblyQualifiedName , obsolete . Message ) ;
612
615
}
616
+
613
617
return type ;
614
618
}
615
619
catch ( HibernateException )
@@ -621,14 +625,17 @@ private static IType HeuristicType(System.Type typeClass, IDictionary<string, st
621
625
throw new MappingException ( "Could not instantiate IType " + typeClass . Name + ": " + e , e ) ;
622
626
}
623
627
}
628
+
624
629
if ( typeof ( ICompositeUserType ) . IsAssignableFrom ( typeClass ) )
625
630
{
626
631
return new CompositeCustomType ( typeClass , parameters ) ;
627
632
}
633
+
628
634
if ( typeof ( IUserType ) . IsAssignableFrom ( typeClass ) )
629
635
{
630
636
return new CustomType ( typeClass , parameters ) ;
631
637
}
638
+
632
639
if ( typeof ( ILifecycle ) . IsAssignableFrom ( typeClass ) )
633
640
{
634
641
return NHibernateUtil . Entity ( typeClass ) ;
0 commit comments