Skip to content

Commit 9b33d4a

Browse files
author
Chris Martinez
committed
API Explorer should support extended ODataValue<T>. Fixes #513
1 parent 79b3e28 commit 9b33d4a

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/Common.OData.ApiExplorer/AspNet.OData/TypeExtensions.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,27 @@ internal static bool IsEnumerable( this Type type, out Type itemType )
296296

297297
static bool IsSingleResult( this Type type ) => type.Is( SingleResultOfT );
298298

299-
static bool IsODataValue( this Type type ) => type.Is( ODataValueOfT );
299+
static bool IsODataValue( this Type type )
300+
{
301+
while ( type != null )
302+
{
303+
if ( !type.IsGenericType )
304+
{
305+
return false;
306+
}
307+
308+
var typeDef = type.GetGenericTypeDefinition();
309+
310+
if ( typeDef.Equals( ODataValueOfT ) )
311+
{
312+
return true;
313+
}
314+
315+
type = type.BaseType;
316+
}
317+
318+
return false;
319+
}
300320

301321
static bool Is( this Type type, Type typeDefinition ) => type.IsGenericType && type.GetGenericTypeDefinition().Equals( typeDefinition );
302322

0 commit comments

Comments
 (0)