System.ComponentModel.PropertyDescriptorCollection.Contains C# (CSharp) Method

Contains() public method

public Contains ( PropertyDescriptor value ) : bool
value PropertyDescriptor
return bool
        public bool Contains(PropertyDescriptor value) {
            return IndexOf(value) >= 0;
        }

Usage Example

        private void AddIdPropertyIfAvailableTo(PropertyDescriptorCollection modelProperties, ModelBindingContext bindingContext)
        {
            PropertyDescriptor idProperty =
                (from PropertyDescriptor property in TypeDescriptor.GetProperties(bindingContext.ModelType)
                 where property.Name == ID_PROPERTY_NAME
                 select property).SingleOrDefault();

            if (idProperty != null && !modelProperties.Contains(idProperty)) {
                modelProperties.Add(idProperty);
            }
        }