Exemplo n.º 1
0
 private void BuildAttributes_BrowsableProperty()
 {
     BrowsableTypeConverter.BrowsableLabelStyleAttribute browsableLabelStyleAttribute = new BrowsableTypeConverter.BrowsableLabelStyleAttribute(this.eBrowsablePropertyLabel);
     this.oCustomAttributes = new AttributeCollection(new Attribute[]
     {
         browsableLabelStyleAttribute
     });
 }
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            BrowsableTypeConverter.BrowsableLabelStyleAttribute browsableLabelStyleAttribute = (BrowsableTypeConverter.BrowsableLabelStyleAttribute)context.PropertyDescriptor.Attributes[typeof(BrowsableTypeConverter.BrowsableLabelStyleAttribute)];
            if (browsableLabelStyleAttribute != null)
            {
                switch (browsableLabelStyleAttribute.LabelStyle)
                {
                case BrowsableTypeConverter.LabelStyle.lsNormal:
                    return(base.ConvertTo(context, culture, RuntimeHelpers.GetObjectValue(value), destinationType));

                case BrowsableTypeConverter.LabelStyle.lsTypeName:
                    return("(" + value.GetType().Name + ")");

                case BrowsableTypeConverter.LabelStyle.lsEllipsis:
                    return("(...)");
                }
            }
            return(base.ConvertTo(context, culture, RuntimeHelpers.GetObjectValue(value), destinationType));
        }
Exemplo n.º 3
0
 private void BuildAttributes_BrowsableProperty()
 {
     BrowsableTypeConverter.BrowsableLabelStyleAttribute style = new BrowsableTypeConverter.BrowsableLabelStyleAttribute(eBrowsablePropertyLabel);
     oCustomAttributes = new AttributeCollection(new Attribute[] { style });
 }