@@ -22,9 +22,7 @@ THE SOFTWARE. */
2222
2323#endregion
2424
25- using System ;
2625using System . Collections . Generic ;
27- using System . Linq ;
2826using System . Reflection ;
2927using Paramore . Brighter . Inbox . Attributes ;
3028
@@ -33,50 +31,19 @@ namespace Paramore.Brighter.Extensions
3331 internal static class ReflectionExtensions
3432 {
3533 internal static IEnumerable < RequestHandlerAttribute > GetOtherHandlersInPipeline ( this MethodInfo targetMethod )
36- {
37- var customAttributes = targetMethod . GetCustomAttributes ( true ) ;
38- return customAttributes
39- . Select ( attr => ( Attribute ) attr )
40- . Where ( a => a . GetType ( ) . BaseType == typeof ( RequestHandlerAttribute ) )
41- . Cast < RequestHandlerAttribute > ( )
42- . ToList ( ) ;
43- }
34+ => targetMethod . GetCustomAttributes < RequestHandlerAttribute > ( true ) ;
4435
4536 internal static IEnumerable < WrapWithAttribute > GetOtherWrapsInPipeline ( this MethodInfo targetMethod )
46- {
47- var customAttributes = targetMethod . GetCustomAttributes ( true ) ;
48- return customAttributes
49- . Select ( attr => ( Attribute ) attr )
50- . Where ( a => a . GetType ( ) . BaseType == typeof ( WrapWithAttribute ) )
51- . Cast < WrapWithAttribute > ( )
52- . ToList ( ) ;
53- }
54-
37+ => targetMethod . GetCustomAttributes < WrapWithAttribute > ( true ) ;
38+
5539 internal static IEnumerable < UnwrapWithAttribute > GetOtherUnwrapsInPipeline ( this MethodInfo targetMethod )
56- {
57- var customAttributes = targetMethod . GetCustomAttributes ( true ) ;
58- return customAttributes
59- . Select ( attr => ( Attribute ) attr )
60- . Where ( a => a . GetType ( ) . BaseType == typeof ( UnwrapWithAttribute ) )
61- . Cast < UnwrapWithAttribute > ( )
62- . ToList ( ) ;
63- }
64-
40+ => targetMethod . GetCustomAttributes < UnwrapWithAttribute > ( true ) ;
41+
6542 internal static bool HasNoInboxAttributesInPipeline ( this MethodInfo targetMethod )
66- {
67- var customAttributes = targetMethod . GetCustomAttributes ( true ) ;
68- return customAttributes
69- . Select ( attr => ( Attribute ) attr )
70- . Any ( a => a . GetType ( ) == typeof ( NoGlobalInboxAttribute ) ) ;
71- }
43+ => targetMethod . IsDefined ( typeof ( NoGlobalInboxAttribute ) , true ) ;
7244
7345 internal static bool HasExistingUseInboxAttributesInPipeline ( this MethodInfo targetMethod )
74- {
75- var customAttributes = targetMethod . GetCustomAttributes ( true ) ;
76- return customAttributes
77- . Select ( attr => ( Attribute ) attr )
78- . Any ( a => a . GetType ( ) == typeof ( UseInboxAttribute )
79- || a . GetType ( ) == typeof ( UseInboxAsyncAttribute ) ) ;
80- }
46+ => targetMethod . IsDefined ( typeof ( UseInboxAttribute ) , true )
47+ || targetMethod . IsDefined ( typeof ( UseInboxAsyncAttribute ) , true ) ;
8148 }
8249}
0 commit comments