Beispiel #1
0
 internal static ExportParameterKind GetExportKind(Mono.Cecil.ICustomAttributeProvider p)
 {
     foreach (CustomAttribute a in p.GetCustomAttributes(typeof(ExportParameterAttribute)))
     {
         return(ToExportParameterAttribute(a).Kind);
     }
     return(ExportParameterKind.Unspecified);
 }
Beispiel #2
0
 static IEnumerable <TAttribute> GetAttributes <TAttribute> (Mono.Cecil.ICustomAttributeProvider p, Func <CustomAttribute, TAttribute> selector)
 {
     return(p.GetCustomAttributes(typeof(TAttribute))
            .Select(selector));
 }
Beispiel #3
0
 /// <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());
 }
Beispiel #4
0
 /// <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());
 }
Beispiel #5
0
 internal static CustomAttribute GetCustomAttribute <T>(this ICustomAttributeProvider instance)
     where T : Attribute => instance.GetCustomAttributes <T>().FirstOrDefault();