7
7
using System . Diagnostics . Contracts ;
8
8
using System . Linq ;
9
9
using System . Reflection ;
10
+ using System . Runtime . CompilerServices ;
10
11
using Microsoft . AspNet . OData . Common ;
11
12
12
13
namespace Microsoft . AspNet . OData . Builder
@@ -525,8 +526,8 @@ private void VerifyBindingPath(NavigationPropertyConfiguration navigationConfigu
525
526
Contract . Assert ( navigationConfiguration != null ) ;
526
527
Contract . Assert ( bindingPath != null ) ;
527
528
528
- PropertyInfo navigation = bindingPath . Last ( ) as PropertyInfo ;
529
- if ( navigation == null || navigation != navigationConfiguration . PropertyInfo )
529
+ MemberInfo navigation = bindingPath . Last ( ) as MemberInfo ;
530
+ if ( navigation == null || navigation != navigationConfiguration . PropertyInfo . MemberInfo )
530
531
{
531
532
throw Error . Argument ( "navigationConfiguration" , SRResources . NavigationPropertyBindingPathIsNotValid ,
532
533
bindingPath . ConvertBindingPath ( ) , navigationConfiguration . Name ) ;
@@ -552,13 +553,25 @@ private static Type VerifyBindingSegment(Type current, MemberInfo info)
552
553
return derivedType . BaseType ;
553
554
}
554
555
556
+ Type declaringType = null ;
557
+ Type propertyType = null ;
555
558
PropertyInfo propertyInfo = info as PropertyInfo ;
556
- if ( propertyInfo == null )
559
+ MethodInfo methodInfo = info as MethodInfo ;
560
+ if ( propertyInfo != null )
561
+ {
562
+ declaringType = info . DeclaringType ;
563
+ propertyType = propertyInfo . PropertyType ;
564
+ }
565
+ else if ( methodInfo != null && methodInfo . GetCustomAttribute < ExtensionAttribute > ( ) != null )
566
+ {
567
+ declaringType = methodInfo . GetParameters ( ) . First ( ) . ParameterType ;
568
+ propertyType = methodInfo . ReturnType ;
569
+ }
570
+ else
557
571
{
558
572
throw Error . NotSupported ( SRResources . NavigationPropertyBindingPathNotSupported , info . Name , info . MemberType ) ;
559
573
}
560
574
561
- Type declaringType = propertyInfo . DeclaringType ;
562
575
if ( declaringType == null ||
563
576
! ( declaringType . IsAssignableFrom ( current ) || current . IsAssignableFrom ( declaringType ) ) )
564
577
{
@@ -567,12 +580,12 @@ private static Type VerifyBindingSegment(Type current, MemberInfo info)
567
580
}
568
581
569
582
Type elementType ;
570
- if ( TypeHelper . IsCollection ( propertyInfo . PropertyType , out elementType ) )
583
+ if ( TypeHelper . IsCollection ( propertyType , out elementType ) )
571
584
{
572
585
return elementType ;
573
586
}
574
587
575
- return propertyInfo . PropertyType ;
588
+ return propertyType ;
576
589
}
577
590
}
578
591
}
0 commit comments