File tree Expand file tree Collapse file tree 1 file changed +23
-20
lines changed
Expand file tree Collapse file tree 1 file changed +23
-20
lines changed Original file line number Diff line number Diff line change 44using System . Linq ;
55using System . Reflection ;
66
7- public static class TypeExtensions
7+ namespace Mvc . JQuery . Datatables
88{
9- public static IEnumerable < PropertyInfo > GetSortedProperties ( this Type t )
9+ public static class TypeExtensions
1010 {
11- return from pi in t . GetProperties ( )
12- let da = ( DisplayAttribute ) pi . GetCustomAttributes ( typeof ( DisplayAttribute ) , false ) . SingleOrDefault ( )
13- let order = ( ( da != null && da . Order != 0 ) ? da . Order : int . MaxValue )
14- orderby order
15- select pi ;
16- }
11+ public static IEnumerable < PropertyInfo > GetSortedProperties ( this Type t )
12+ {
13+ return from pi in t . GetProperties ( )
14+ let da = ( DisplayAttribute ) pi . GetCustomAttributes ( typeof ( DisplayAttribute ) , false ) . SingleOrDefault ( )
15+ let order = ( ( da != null && da . GetOrder ( ) != null && da . GetOrder ( ) >= 0 ) ? da . Order : int . MaxValue )
16+ orderby order
17+ select pi ;
18+ }
1719
18- public static IEnumerable < PropertyInfo > GetSortedProperties < T > ( )
19- {
20- return typeof ( T ) . GetSortedProperties ( ) ;
21- }
22- public static IEnumerable < PropertyInfo > GetProperties ( this Type t )
23- {
24- return from pi in t . GetProperties ( )
25- select pi ;
26- }
20+ public static IEnumerable < PropertyInfo > GetSortedProperties < T > ( )
21+ {
22+ return typeof ( T ) . GetSortedProperties ( ) ;
23+ }
24+ public static IEnumerable < PropertyInfo > GetProperties ( this Type t )
25+ {
26+ return from pi in t . GetProperties ( )
27+ select pi ;
28+ }
2729
28- public static IEnumerable < PropertyInfo > GetProperties < T > ( )
29- {
30- return typeof ( T ) . GetSortedProperties ( ) ;
30+ public static IEnumerable < PropertyInfo > GetProperties < T > ( )
31+ {
32+ return typeof ( T ) . GetSortedProperties ( ) ;
33+ }
3134 }
3235}
You can’t perform that action at this time.
0 commit comments