コード例 #1
0
        public void Ctor_Default()
        {
            var attribute = new DescriptionAttribute();

            Assert.Equal(string.Empty, attribute.Description);
            Assert.True(attribute.IsDefaultAttribute());
        }
コード例 #2
0
        public void Ctor_Description(string description, bool expectedIsDefaultAttribute)
        {
            var attribute = new DescriptionAttribute(description);

            Assert.Equal(description, attribute.Description);
            Assert.Equal(expectedIsDefaultAttribute, attribute.IsDefaultAttribute());
        }
コード例 #3
0
        /// <summary>
        /// Configures additional attributes for an option item or option group, such as collapsed state and group visibility.
        /// </summary>
        /// <param name="item">The item or group to configure.</param>
        /// <param name="propertyInfo">The associated property info.</param>
        protected virtual void ConfigureItem(IOptionItem item, PropertyInfo propertyInfo)
        {
            NullableAttribute nullableAttribute =
                (NullableAttribute)Attribute.GetCustomAttribute(propertyInfo, typeof(NullableAttribute));

            if (nullableAttribute != null)
            {
                item.Attributes[OptionItem.SupportNullValueAttribute] = nullableAttribute.IsNullable;
            }
            else
            {
                CanBeNullAttribute canBeNull =
                    (CanBeNullAttribute)Attribute.GetCustomAttribute(propertyInfo, typeof(CanBeNullAttribute));
                NotNullAttribute notNull =
                    (NotNullAttribute)Attribute.GetCustomAttribute(propertyInfo, typeof(NotNullAttribute));
                if (canBeNull != null)
                {
                    item.Attributes[OptionItem.SupportNullValueAttribute] = true;
                }
                else if (notNull != null)
                {
                    item.Attributes[OptionItem.SupportNullValueAttribute] = false;
                }
            }

            DescriptionAttribute attribute = GetAttribute <DescriptionAttribute>(propertyInfo);

            if (attribute != null && !attribute.IsDefaultAttribute())
            {
                item.Attributes[OptionItem.DescriptionAttribute] = attribute.Description;
            }

            var customAttributes = Attribute.GetCustomAttributes(propertyInfo);

            foreach (var attrib in customAttributes.OfType <OptionItemAttributeAttribute>())
            {
                item.Attributes[attrib.Name] = attrib.Value;
            }
        }
        /// <summary>
        /// Configures additional attributes for an option item or option group, such as collapsed state and group visibility.
        /// </summary>
        /// <param name="item">The item or group to configure.</param>
        /// <param name="propertyInfo">The associated property info.</param>
        protected virtual void ConfigureItem(IOptionItem item, PropertyInfo propertyInfo)
        {
            TableEditorFactory.RenderingHints   tableRenderingHints   = TableEditorFactory.RenderingHints.Collapsed;
            DefaultEditorFactory.RenderingHints defaultRenderingHints = DefaultEditorFactory.RenderingHints.Invisible;
            ItemRenderingHintsAttribute         hintsAttribute        =
                (ItemRenderingHintsAttribute)Attribute.GetCustomAttribute(propertyInfo, typeof(ItemRenderingHintsAttribute));

            if (hintsAttribute != null)
            {
                tableRenderingHints   = hintsAttribute.TableRenderingHints;
                defaultRenderingHints = hintsAttribute.DialogRenderingHints;
            }
            item.SetAttribute(TableEditorFactory.RENDERING_HINTS_ATTRIBUTE, tableRenderingHints);
            item.SetAttribute(DefaultEditorFactory.RENDERING_HINTS_ATTRIBUTE, defaultRenderingHints);

            NullableAttribute nullableAttribute =
                (NullableAttribute)Attribute.GetCustomAttribute(propertyInfo, typeof(NullableAttribute));

            if (nullableAttribute != null)
            {
                item.SetAttribute(OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, nullableAttribute.IsNullable);
            }

            DescriptionAttribute attribute = GetAttribute <DescriptionAttribute>(propertyInfo);

            if (attribute != null && !attribute.IsDefaultAttribute())
            {
                item.SetAttribute(OptionItem.DESCRIPTION_ATTRIBUTE, attribute.Description);
            }

            var customAttributes = Attribute.GetCustomAttributes(propertyInfo);

            foreach (var attrib in customAttributes.OfType <OptionItemAttributeAttribute>())
            {
                item.SetAttribute(attrib.Name, attrib.Value);
            }
        }