@@ -15,7 +15,8 @@ public static class PropertyFinder
15
15
/// <summary>
16
16
/// List of types to exclude from the types of components in the UI we can bind to.
17
17
/// </summary>
18
- private static readonly HashSet < Type > hiddenTypes = new HashSet < Type > {
18
+ private static readonly HashSet < Type > hiddenTypes = new HashSet < Type >
19
+ {
19
20
typeof ( AbstractMemberBinding ) ,
20
21
typeof ( OneWayPropertyBinding ) ,
21
22
typeof ( TwoWayPropertyBinding )
@@ -24,24 +25,31 @@ public static class PropertyFinder
24
25
/// <summary>
25
26
/// Use reflection to find all components with properties we can bind to.
26
27
/// </summary>
27
- public static IEnumerable < BindableMember < PropertyInfo > > GetBindableProperties ( GameObject gameObject ) //todo: Maybe move this to the TypeResolver.
28
+ public static BindableMember < PropertyInfo > [ ] GetBindableProperties ( GameObject gameObject ) //todo: Maybe move this to the TypeResolver.
28
29
{
30
+ BindableMember < PropertyInfo > [ ] bindableProperties ;
29
31
using ( var cache = gameObject . GetComponentsWithCache < Component > ( ) )
30
32
{
31
- return cache . Components
32
- . SelectMany ( component =>
33
- {
34
- var type = component . GetType ( ) ;
35
- return type
36
- . GetProperties ( BindingFlags . Instance | BindingFlags . Public )
37
- . Select ( p => new BindableMember < PropertyInfo > ( p , type ) ) ;
38
- } )
39
- . Where ( prop => prop . Member . GetSetMethod ( false ) != null
40
- && prop . Member . GetGetMethod ( false ) != null
41
- && ! hiddenTypes . Contains ( prop . ViewModelType )
42
- && ! prop . Member . GetCustomAttributes ( typeof ( ObsoleteAttribute ) , true ) . Any ( )
43
- ) ;
33
+ bindableProperties = cache . Components
34
+ . SelectMany ( component =>
35
+ {
36
+ var type = component . GetType ( ) ;
37
+ return type
38
+ . GetProperties ( BindingFlags . Instance | BindingFlags . Public )
39
+ . Select ( p => new BindableMember < PropertyInfo > ( p , type ) ) ;
40
+ } )
41
+ . Where ( prop => prop . Member . GetSetMethod ( false ) != null
42
+ && prop . Member . GetGetMethod ( false ) != null
43
+ && ! hiddenTypes . Contains ( prop . ViewModelType )
44
+ && ! prop . Member
45
+ . GetCustomAttributes ( typeof ( ObsoleteAttribute ) , true )
46
+ . Any ( )
47
+ ) . OrderBy ( prop => prop . ViewModelTypeName )
48
+ . ThenBy ( prop => prop . MemberName )
49
+ . ToArray ( ) ;
44
50
}
51
+
52
+ return bindableProperties ;
45
53
}
46
54
}
47
- }
55
+ }
0 commit comments