void CopyAttributes(IList <CustomAttributeData> src, ICustomAttributesContainer target) { foreach (CustomAttributeData cad in src) { target.SetCustomAttribute(_assemblyFixer.CustomAttributeData(cad)); } }
public static T GetCustomAttribute <T>(this ICustomAttributesContainer container) where T : Attribute { return(container .GetCustomAttributes <T>() .SingleOrDefaultOrThrow( () => throw new AppRunnerException($"attempted to get a single {typeof(T).Name} from {container} but multiple exist"))); }
public static bool HasAttribute <T>(this ICustomAttributesContainer container) where T : Attribute { if (container == null) { throw new ArgumentNullException(nameof(container)); } return(container.CustomAttributes?.HasAttribute <T>() ?? false); }
public static IEnumerable <T> GetCustomAttributes <T>(this ICustomAttributesContainer container) where T : Attribute { if (container == null) { throw new ArgumentNullException(nameof(container)); } return(container.CustomAttributes?.GetCustomAttributes(typeof(T), false).Cast <T>()); }
void CopyAttributes(ParameterInfo src, ICustomAttributesContainer target) => CopyAttributes(src.GetCustomAttributesData(), target);