You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
651 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
#if FEATURE_REFLECTION_TYPEINFO
using System.Reflection;
#endif // FEATURE_REFLECTION_TYPEINFO
namespace Renci.SshNet.Abstractions
{
internal static class ReflectionAbstraction
{
public static IEnumerable<T> GetCustomAttributes<T>(this Type type, bool inherit)
where T:Attribute
{
#if FEATURE_REFLECTION_TYPEINFO
return type.GetTypeInfo().GetCustomAttributes<T>(inherit);
#else
var attributes = type.GetCustomAttributes(typeof(T), inherit);
return new List<T>(attributes.Cast<T>());
#endif
}
}
}