public static TAttribute GetCustomAttribute <TAttribute>(this BaseDto obj, string propertyName) where TAttribute : Attribute { TAttribute fieldAttribute = obj.GetType().GetPublicProperties() .SingleOrDefault(property => property.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase))? .GetCustomAttribute <TAttribute>(); return(fieldAttribute); }
public static TAttribute GetObjectLevelCustomAttribute <TAttribute>(this BaseDto obj) where TAttribute : Attribute { TAttribute fieldAttribute = obj.GetType().GetCustomAttribute <TAttribute>(); return(fieldAttribute); }