internal static ExportParameterKind GetExportKind(Mono.Cecil.ICustomAttributeProvider p) { foreach (CustomAttribute a in p.GetCustomAttributes(typeof(ExportParameterAttribute))) { return(ToExportParameterAttribute(a).Kind); } return(ExportParameterKind.Unspecified); }
static IEnumerable <TAttribute> GetAttributes <TAttribute> (Mono.Cecil.ICustomAttributeProvider p, Func <CustomAttribute, TAttribute> selector) { return(p.GetCustomAttributes(typeof(TAttribute)) .Select(selector)); }
/// <summary> /// Gets the custom attribute. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="provider">The provider.</param> /// <returns></returns> public static T GetCustomAttribute <T>(this ICustomAttributeProvider provider) { return(provider.GetCustomAttributes <T>().FirstOrDefault()); }
/// <summary> /// Determines whether the custom attribute provider has the right custom attribute. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="memberDef">The member definition.</param> /// <returns></returns> public static bool HasCustomAttribute <T>(this ICustomAttributeProvider memberDef) { return(memberDef.GetCustomAttributes <T>().Any()); }
internal static CustomAttribute GetCustomAttribute <T>(this ICustomAttributeProvider instance) where T : Attribute => instance.GetCustomAttributes <T>().FirstOrDefault();