Пример #1
0
        /// <summary>
        /// Gets the category for the specified property.
        /// </summary>
        /// <param name="pd">The property descriptor.</param>
        /// <returns>The category.</returns>
        public static string GetCategory(this System.ComponentModel.PropertyDescriptor pd)
        {
            var a = pd.GetFirstAttributeOrDefault <DataAnnotations.CategoryAttribute>();

            if (a != null)
            {
                return(a.Category);
            }

            return(pd.Category);
        }
Пример #2
0
        /// <summary>
        /// Gets the display name for the specified property.
        /// </summary>
        /// <param name="pd">The property descriptor.</param>
        /// <returns>The display name.</returns>
        public static string GetDisplayName(this System.ComponentModel.PropertyDescriptor pd)
        {
            var a = pd.GetFirstAttributeOrDefault <DataAnnotations.DisplayNameAttribute>();

            if (a != null)
            {
                return(a.DisplayName);
            }

            return(pd.DisplayName);
        }
Пример #3
0
        /// <summary>
        /// Determines whether the property is read-only.
        /// </summary>
        /// <param name="pd">The property descriptor.</param>
        /// <returns><c>true</c> if the property is read-only; otherwise, <c>false</c>.</returns>
        public static bool IsReadOnly(this System.ComponentModel.PropertyDescriptor pd)
        {
            var a = pd.GetFirstAttributeOrDefault <DataAnnotations.ReadOnlyAttribute>();

            if (a != null)
            {
                return(a.IsReadOnly);
            }

            return(pd.IsReadOnly);
        }