@@ -99,7 +99,8 @@ public PagedCollection(int pageSize = 50)
9999 /// <param name="items">The source collection.</param>
100100 public void SetSource ( IReadOnlyList < T > items )
101101 {
102- _source = items ?? throw new ArgumentNullException ( nameof ( items ) ) ;
102+ ArgumentNullException . ThrowIfNull ( items ) ;
103+ _source = items ;
103104 ApplyFiltering ( ) ;
104105 SourceChanged ? . Invoke ( this , EventArgs . Empty ) ;
105106 }
@@ -110,6 +111,7 @@ public void SetSource(IReadOnlyList<T> items)
110111 /// <param name="filter">The filter to add.</param>
111112 public void AddFilter ( Func < T , bool > filter )
112113 {
114+ ArgumentNullException . ThrowIfNull ( filter ) ;
113115 SetFilter ( Guid . NewGuid ( ) . ToString ( ) , filter ) ;
114116 }
115117
@@ -120,6 +122,8 @@ public void AddFilter(Func<T, bool> filter)
120122 /// <param name="filter">The filter to add or update.</param>
121123 public void SetFilter ( string key , Func < T , bool > filter )
122124 {
125+ ArgumentNullException . ThrowIfNull ( key ) ;
126+ ArgumentNullException . ThrowIfNull ( filter ) ;
123127 _filters [ key ] = filter ;
124128 ApplyFiltering ( ) ;
125129 FilterChanged ? . Invoke ( this , EventArgs . Empty ) ;
@@ -131,6 +135,7 @@ public void SetFilter(string key, Func<T, bool> filter)
131135 /// <param name="key">The key of the filter to remove.</param>
132136 public void RemoveFilter ( string key )
133137 {
138+ ArgumentNullException . ThrowIfNull ( key ) ;
134139 if ( _filters . Remove ( key ) )
135140 {
136141 ApplyFiltering ( ) ;
@@ -164,6 +169,7 @@ public void ClearFilters()
164169 /// <param name="debounceMilliseconds">Optional. The number of milliseconds to debounce the search. If 0, no debouncing occurs.</param>
165170 public void SetSearch ( Func < T , string > selector , string ? term , bool useWildcards = false , int debounceMilliseconds = 0 )
166171 {
172+ ArgumentNullException . ThrowIfNull ( selector ) ;
167173 SetSearch ( [ selector ] , term , useWildcards , debounceMilliseconds ) ;
168174 }
169175
@@ -176,7 +182,8 @@ public void SetSearch(Func<T, string> selector, string? term, bool useWildcards
176182 /// <param name="debounceMilliseconds">Optional. The number of milliseconds to debounce the search. If 0, no debouncing occurs.</param>
177183 public void SetSearch ( IEnumerable < Func < T , string > > selectors , string ? term , bool useWildcards = false , int debounceMilliseconds = 0 )
178184 {
179- _searchSelectors = selectors ?? throw new ArgumentNullException ( nameof ( selectors ) ) ;
185+ ArgumentNullException . ThrowIfNull ( selectors ) ;
186+ _searchSelectors = selectors ;
180187 _searchTerm = term ;
181188 _useWildcards = useWildcards ;
182189
@@ -206,7 +213,8 @@ public void SetSearch(IEnumerable<Func<T, string>> selectors, string? term, bool
206213 /// <param name="debounceMilliseconds">Optional. The number of milliseconds to debounce the search. If 0, no debouncing occurs.</param>
207214 public void SetSearchAll ( IEnumerable < Func < T , string > > selectors , string ? term , bool useWildcards = false , int debounceMilliseconds = 0 )
208215 {
209- _searchSelectors = selectors ?? throw new ArgumentNullException ( nameof ( selectors ) ) ;
216+ ArgumentNullException . ThrowIfNull ( selectors ) ;
217+ _searchSelectors = selectors ;
210218 _searchTerm = term ;
211219 _useWildcards = useWildcards ;
212220
@@ -297,6 +305,7 @@ public void ClearSearch()
297305 /// <param name="ascending">A value indicating whether to sort in ascending order.</param>
298306 public void SetSort < TKey > ( Func < T , TKey > selector , bool ascending )
299307 {
308+ ArgumentNullException . ThrowIfNull ( selector ) ;
300309 _sorts . Clear ( ) ;
301310 _sorts . Add ( ( x => selector ( x ) ! , ascending ) ) ;
302311 ApplyFiltering ( ) ;
0 commit comments