Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public static TAttribute GetObjectLevelCustomAttribute <TAttribute>(this BaseDto obj) where TAttribute : Attribute
        {
            TAttribute fieldAttribute = obj.GetType().GetCustomAttribute <TAttribute>();

            return(fieldAttribute);
        }