public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object obj, Attribute[] attributes)
        {
            PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(null);
            CustomAttributes             customAttributes             = obj as CustomAttributes;

            if (customAttributes != null && context != null)
            {
                Series series = (customAttributes.DataPointAttributes is Series) ? ((Series)customAttributes.DataPointAttributes) : customAttributes.DataPointAttributes.series;
                if (series != null && series.chart != null && series.chart.chartPicture != null && series.chart.chartPicture.common != null)
                {
                    CustomAttributeRegistry customAttributeRegistry = (CustomAttributeRegistry)series.chart.chartPicture.common.container.GetService(typeof(CustomAttributeRegistry));
                    foreach (CustomAttributeInfo registeredCustomAttribute in customAttributeRegistry.registeredCustomAttributes)
                    {
                        if (this.IsApplicableCustomAttribute(registeredCustomAttribute, context.Instance))
                        {
                            Attribute[] propertyAttributes           = this.GetPropertyAttributes(registeredCustomAttribute);
                            CustomAttributesPropertyDescriptor value = new CustomAttributesPropertyDescriptor(typeof(CustomAttributes), registeredCustomAttribute.Name, registeredCustomAttribute.ValueType, propertyAttributes, registeredCustomAttribute);
                            propertyDescriptorCollection.Add(value);
                        }
                    }
                    Attribute[] attributes2 = new Attribute[3]
                    {
                        new NotifyParentPropertyAttribute(true),
                        new RefreshPropertiesAttribute(RefreshProperties.All),
                        new DescriptionAttribute(SR.DescriptionAttributeUserDefined)
                    };
                    CustomAttributesPropertyDescriptor value2 = new CustomAttributesPropertyDescriptor(typeof(CustomAttributes), "UserDefined", typeof(string), attributes2, null);
                    propertyDescriptorCollection.Add(value2);
                }
            }
            return(propertyDescriptorCollection);
        }
        public virtual string GetUserDefinedAttributes(bool userDefined)
        {
            string customAttributes = this.DataPointAttributes.CustomAttributes;
            string text             = string.Empty;
            Series series           = (this.DataPointAttributes is Series) ? ((Series)this.DataPointAttributes) : this.DataPointAttributes.series;
            CustomAttributeRegistry customAttributeRegistry = (CustomAttributeRegistry)series.chart.chartPicture.common.container.GetService(typeof(CustomAttributeRegistry));

            customAttributes = customAttributes.Replace("\\,", "\\x45");
            customAttributes = customAttributes.Replace("\\=", "\\x46");
            if (customAttributes.Length > 0)
            {
                string[] array  = customAttributes.Split(',');
                string[] array2 = array;
                foreach (string text2 in array2)
                {
                    string[] array3 = text2.Split('=');
                    if (array3.Length != 2)
                    {
                        throw new FormatException(SR.ExceptionAttributeInvalidFormat);
                    }
                    array3[0] = array3[0].Trim();
                    array3[1] = array3[1].Trim();
                    if (array3[0].Length == 0)
                    {
                        throw new FormatException(SR.ExceptionAttributeInvalidFormat);
                    }
                    bool flag = true;
                    foreach (CustomAttributeInfo registeredCustomAttribute in customAttributeRegistry.registeredCustomAttributes)
                    {
                        if (string.Compare(registeredCustomAttribute.Name, array3[0], StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            flag = false;
                        }
                    }
                    if (flag == userDefined)
                    {
                        if (text.Length > 0)
                        {
                            text += ", ";
                        }
                        string text3 = array3[1].Replace("\\x45", ",");
                        text3 = text3.Replace("\\x46", "=");
                        text  = text + array3[0] + "=" + text3;
                    }
                }
            }
            return(text);
        }