File tree Expand file tree Collapse file tree 1 file changed +12
-15
lines changed
Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . Collections ;
33using System . Collections . Generic ;
4+ using WinUI . TableView . Extensions ;
45
56namespace WinUI . TableView ;
67
@@ -9,6 +10,8 @@ namespace WinUI.TableView;
910/// </summary>
1011public class SortDescription
1112{
13+ private Func < object , object ? > ? _funcCompiled ;
14+
1215 /// <summary>
1316 /// Initializes a new instance of the <see cref="SortDescription"/> class that describes
1417 /// a sort on the object itself
@@ -35,21 +38,15 @@ public SortDescription(string? propertyName,
3538 /// <returns>The value of the property.</returns>
3639 public virtual object ? GetPropertyValue ( object ? item )
3740 {
38- if ( ValueDelegate is not null )
39- {
40- return ValueDelegate ( item ) ;
41- }
42- else if ( PropertyName is not null )
43- {
44- return item ? . GetType ( )
45- . GetProperty ( PropertyName ) ?
46- . GetValue ( item ) ;
47- }
48- else
49- {
50- return default ! ;
51- }
52- }
41+ if ( item == null ) return null ;
42+
43+ if ( ValueDelegate is not null ) return ValueDelegate ( item ) ;
44+
45+ if ( _funcCompiled is null && ! string . IsNullOrWhiteSpace ( PropertyName ) )
46+ _funcCompiled = item . GetFuncCompiledPropertyPath ( PropertyName ! ) ;
47+
48+ return _funcCompiled ? . Invoke ( item ) ;
49+ }
5350
5451 /// <summary>
5552 /// Compares two objects based on the sort description.
You can’t perform that action at this time.
0 commit comments