1
1
using System ;
2
- using System . Collections ;
3
2
using NHibernate . Engine ;
4
3
using NHibernate . Type ;
5
4
using System . Collections . Generic ;
@@ -17,7 +16,7 @@ public class FilterImpl : IFilter
17
16
private FilterDefinition definition ;
18
17
19
18
private readonly IDictionary < string , object > parameters = new Dictionary < string , object > ( ) ;
20
- private readonly IDictionary < string , IEnumerable > _parameterLists = new Dictionary < string , IEnumerable > ( ) ;
19
+ private readonly Dictionary < string , int > _parameterSpans = new Dictionary < string , int > ( ) ;
21
20
22
21
public void AfterDeserialize ( FilterDefinition factoryDefinition )
23
22
{
@@ -80,20 +79,17 @@ public IFilter SetParameter(string name, object value)
80
79
/// <exception cref="ArgumentNullException">Thrown when <paramref name="name"/> or <paramref name="values"/> are <see langword="null" />.</exception>
81
80
public IFilter SetParameterList < T > ( string name , ICollection < T > values )
82
81
{
82
+ if ( values == null )
83
+ throw new ArgumentNullException ( nameof ( values ) , "Collection must be not null!" ) ;
84
+
83
85
var type = definition . GetParameterType ( name ) ;
84
86
if ( type == null )
85
- {
86
87
throw new HibernateException ( "Undefined filter parameter [" + name + "]" ) ;
87
- }
88
88
89
89
if ( ! type . ReturnedClass . IsAssignableFrom ( typeof ( T ) ) )
90
- {
91
90
throw new HibernateException ( "Incorrect type for parameter [" + name + "]" ) ;
92
- }
93
91
94
- _parameterLists [ name ] = values ??
95
- // This guarantees GetParameterList semantic.
96
- throw new ArgumentNullException ( nameof ( values ) , "Collection must be not null!" ) ;
92
+ _parameterSpans [ name ] = values . Count ;
97
93
parameters [ name ] = values ;
98
94
return this ;
99
95
}
@@ -106,14 +102,15 @@ public object GetParameter(string name)
106
102
}
107
103
108
104
/// <summary>
109
- /// Get a parameter list by name. <see langword="null" /> if there is no parameter list for that name.
105
+ /// Get a span of collection parameter by name. <see langword="null" /> if the parameter is not a collectino or
106
+ /// there is no such parameter exist.
110
107
/// </summary>
111
108
/// <param name="name">The parameter name.</param>
112
- /// <returns>The parameter list, or <see langword="null" /> if there is no parameter list for that name.</returns>
113
- public IEnumerable GetParameterList ( string name )
109
+ /// <returns>The parameter span, or <see langword="null" /> if the parameter is not a collectino or
110
+ /// there is no such parameter exist.</returns>
111
+ public int ? GetParameterSpan ( string name )
114
112
{
115
- _parameterLists . TryGetValue ( name , out var result ) ;
116
- return result ;
113
+ return _parameterSpans . TryGetValue ( name , out var result ) ? result : default ( int ? ) ;
117
114
}
118
115
119
116
/// <summary>
0 commit comments