Skip to content

Commit 183c8f4

Browse files
committed
Added support for .NET 4.0
1 parent fbc8a42 commit 183c8f4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Extensions/Reflection/IntrospectionExtensions.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Linq;
23
using System.Threading;
34

45
namespace System.Reflection
@@ -35,6 +36,8 @@ internal TypeInfo(Type type)
3536

3637
public Type AsType() => _type;
3738

39+
public bool IsAssignableFrom(Type type) => _type.IsAssignableFrom(type);
40+
3841
public bool IsAssignableFrom(TypeInfo typeInfo) => _type.IsAssignableFrom(typeInfo.AsType());
3942

4043
public bool IsGenericParameter => _type.IsGenericParameter;
@@ -195,6 +198,14 @@ public override bool Equals(object obj)
195198
internal static class IntrospectionExtensions
196199
{
197200
#if NET40
201+
202+
public static Attribute GetCustomAttribute(this ParameterInfo info, Type type)
203+
{
204+
return info.GetCustomAttributes(type, true)
205+
.Cast<Attribute>()
206+
.FirstOrDefault();
207+
}
208+
198209
public static TypeInfo GetTypeInfo(this Type type)
199210
{
200211
if (type == null)

0 commit comments

Comments
 (0)