Example #1
0
        /// <summary>
        /// Adds the property.
        /// </summary>
        /// <param name="property">The property.</param>
        public void AddProperty(PropertyItem property)
        {
            if (property == null)
            {
                throw new ArgumentNullException(nameof(property));
            }
            if (_properties.Contains(property))
            {
                throw new ArgumentException("Cannot add a duplicated property " + property.Name);
            }

            int index = _properties.BinarySearch(property, _comparer);

            if (index < 0)
            {
                index = ~index;
            }

            _properties.Insert(index, property);

            if (property.IsBrowsable)
            {
                HasVisibleProperties = true;
            }
            else
            {
                HasVisibleProperties = _properties.Any(IsPropertyVisible);
            }

            property.BrowsableChanged += PropertyBrowsableChanged;
        }