@@ -14,29 +14,27 @@ internal static class ParameterHelper
1414 /// </summary>
1515 /// <param name="param">The object to guess the <see cref="IType"/> of.</param>
1616 /// <param name="sessionFactory">The session factory to search for entity persister.</param>
17- /// <param name="isCollection">The output parameter that represents whether the <paramref name="param"/> is a collection.</param>
17+ /// <param name="isCollection">Whether <paramref name="param"/> is a collection.</param>
1818 /// <returns>An <see cref="IType"/> for the object.</returns>
1919 /// <exception cref="ArgumentNullException">
2020 /// Thrown when the <c>param</c> is null because the <see cref="IType"/>
2121 /// can't be guess from a null value.
2222 /// </exception>
23- public static IType TryGuessType ( object param , ISessionFactoryImplementor sessionFactory , out bool isCollection )
23+ public static IType TryGuessType ( object param , ISessionFactoryImplementor sessionFactory , bool isCollection )
2424 {
2525 if ( param == null )
2626 {
27- throw new ArgumentNullException ( nameof ( param ) , "The IType can not be guessed for a null value." ) ;
27+ return null ;
2828 }
2929
30- if ( param is IEnumerable enumerable && ! ( param is string ) )
30+ if ( param is IEnumerable enumerable && isCollection )
3131 {
3232 var firstValue = enumerable . Cast < object > ( ) . FirstOrDefault ( ) ;
33- isCollection = true ;
3433 return firstValue == null
3534 ? TryGuessType ( enumerable . GetCollectionElementType ( ) , sessionFactory )
36- : TryGuessType ( firstValue , sessionFactory , out _ ) ;
35+ : TryGuessType ( firstValue , sessionFactory , false ) ;
3736 }
3837
39- isCollection = false ;
4038 var clazz = NHibernateProxyHelper . GetClassWithoutInitializingProxy ( param ) ;
4139 return TryGuessType ( clazz , sessionFactory ) ;
4240 }
@@ -67,26 +65,24 @@ public static IType GuessType(object param, ISessionFactoryImplementor sessionFa
6765 /// </summary>
6866 /// <param name="clazz">The <see cref="System.Type"/> to guess the <see cref="IType"/> of.</param>
6967 /// <param name="sessionFactory">The session factory to search for entity persister.</param>
70- /// <param name="isCollection">The output parameter that represents whether the <paramref name="clazz"/> is a collection.</param>
68+ /// <param name="isCollection">Whether <paramref name="clazz"/> is a collection.</param>
7169 /// <returns>An <see cref="IType"/> for the <see cref="System.Type"/>.</returns>
7270 /// <exception cref="ArgumentNullException">
7371 /// Thrown when the <c>clazz</c> is null because the <see cref="IType"/>
7472 /// can't be guess from a null type.
7573 /// </exception>
76- public static IType TryGuessType ( System . Type clazz , ISessionFactoryImplementor sessionFactory , out bool isCollection )
74+ public static IType TryGuessType ( System . Type clazz , ISessionFactoryImplementor sessionFactory , bool isCollection )
7775 {
7876 if ( clazz == null )
7977 {
80- throw new ArgumentNullException ( nameof ( clazz ) , "The IType can not be guessed for a null value." ) ;
78+ return null ;
8179 }
8280
83- if ( clazz . IsCollectionType ( ) )
81+ if ( isCollection )
8482 {
85- isCollection = true ;
86- return TryGuessType ( ReflectHelper . GetCollectionElementType ( clazz ) , sessionFactory , out _ ) ;
83+ return TryGuessType ( ReflectHelper . GetCollectionElementType ( clazz ) , sessionFactory , false ) ;
8784 }
8885
89- isCollection = false ;
9086 return TryGuessType ( clazz , sessionFactory ) ;
9187 }
9288
@@ -95,41 +91,18 @@ public static IType TryGuessType(System.Type clazz, ISessionFactoryImplementor s
9591 /// </summary>
9692 /// <param name="clazz">The <see cref="System.Type"/> to guess the <see cref="IType"/> of.</param>
9793 /// <param name="sessionFactory">The session factory to search for entity persister.</param>
98- /// <param name="isCollection">The output parameter that represents whether the <paramref name="clazz"/> is a collection.</param>
9994 /// <returns>An <see cref="IType"/> for the <see cref="System.Type"/>.</returns>
10095 /// <exception cref="ArgumentNullException">
10196 /// Thrown when the <c>clazz</c> is null because the <see cref="IType"/>
10297 /// can't be guess from a null type.
10398 /// </exception>
104- public static IType GuessType ( System . Type clazz , ISessionFactoryImplementor sessionFactory , out bool isCollection )
99+ public static IType GuessType ( System . Type clazz , ISessionFactoryImplementor sessionFactory )
105100 {
106101 if ( clazz == null )
107102 {
108103 throw new ArgumentNullException ( nameof ( clazz ) , "The IType can not be guessed for a null value." ) ;
109104 }
110105
111- if ( typeof ( IEnumerable ) . IsAssignableFrom ( clazz ) && typeof ( string ) != clazz )
112- {
113- isCollection = true ;
114- return GuessType ( ReflectHelper . GetCollectionElementType ( clazz ) , sessionFactory ) ;
115- }
116-
117- isCollection = false ;
118- return GuessType ( clazz , sessionFactory ) ;
119- }
120-
121- /// <summary>
122- /// Guesses the <see cref="IType"/> from the <see cref="System.Type"/>.
123- /// </summary>
124- /// <param name="clazz">The <see cref="System.Type"/> to guess the <see cref="IType"/> of.</param>
125- /// <param name="sessionFactory">The session factory to search for entity persister.</param>
126- /// <returns>An <see cref="IType"/> for the <see cref="System.Type"/>.</returns>
127- /// <exception cref="ArgumentNullException">
128- /// Thrown when the <c>clazz</c> is null because the <see cref="IType"/>
129- /// can't be guess from a null type.
130- /// </exception>
131- public static IType GuessType ( System . Type clazz , ISessionFactoryImplementor sessionFactory )
132- {
133106 return TryGuessType ( clazz , sessionFactory ) ??
134107 throw new HibernateException ( "Could not determine a type for class: " + clazz . AssemblyQualifiedName ) ;
135108 }
@@ -148,7 +121,7 @@ public static IType TryGuessType(System.Type clazz, ISessionFactoryImplementor s
148121 {
149122 if ( clazz == null )
150123 {
151- throw new ArgumentNullException ( nameof ( clazz ) , "The IType can not be guessed for a null value." ) ;
124+ return null ;
152125 }
153126
154127 var type = TypeFactory . HeuristicType ( clazz ) ;
0 commit comments