File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ namespace UnityEventAggregator
77{
88 public class BaseClass : MonoBehaviour
99 {
10+ private Type [ ] _typeCache ;
11+
1012 void Start ( )
1113 {
1214 GetListenerTypes ( ) . Each ( x => EventAggregator . Register ( this , x ) ) ;
@@ -19,12 +21,18 @@ void OnDestroy()
1921
2022 IEnumerable < Type > GetListenerTypes ( )
2123 {
22- return GetType ( )
23- . GetInterfaces ( )
24- . Where ( x => x . IsGenericType )
25- . Where ( x => x . GetGenericTypeDefinition ( ) == typeof ( IListener < > ) )
26- . Select ( x => x . GetGenericArguments ( ) )
27- . First ( ) ;
24+ if ( _typeCache != null ) return _typeCache ;
25+
26+ var types = GetType ( )
27+ . GetInterfaces ( )
28+ . Where ( x => x . IsGenericType )
29+ . Where ( x => x . GetGenericTypeDefinition ( ) == typeof ( IListener < > ) )
30+ . Select ( x => x . GetGenericArguments ( ) )
31+ . First ( ) ;
32+
33+ _typeCache = types ;
34+
35+ return types ;
2836 }
2937 }
3038}
Original file line number Diff line number Diff line change 3535 <Reference Include =" System.Core" />
3636 <Reference Include =" System.Xml.Linq" />
3737 <Reference Include =" System.Data.DataSetExtensions" />
38- <Reference Include =" Microsoft.CSharp" />
3938 <Reference Include =" System.Data" />
4039 <Reference Include =" System.Xml" />
4140 <Reference Include =" UnityEngine" >
You can’t perform that action at this time.
0 commit comments