ExpandableCollectionConverter Class
Represents a type converter that is capable of expanding various collection types.
public class ExpandableCollectionConverter : TypeConverter, ICollectionTypeConverter
- Inheritance:
- Object Object
- Implements:
- ICollectionTypeConverter
Constructors
ExpandableCollectionConverter()
Initializes a new instance of the ExpandableCollectionConverter class.
public ExpandableCollectionConverter()
ExpandableCollectionConverter(Boolean, Boolean)
Initializes a new instance of the ExpandableCollectionConverter class.
public ExpandableCollectionConverter(bool isCollectionReadOnly, bool areItemsReadOnly)
Parameter | Type | Description |
---|---|---|
isCollectionReadOnly | Boolean | Whether items can be added to or removed from the collection. |
areItemsReadOnly | Boolean | Whether the values of the items in the collection are read-only and cannot be changed. |
Properties
AreItemsReadOnly
Gets whether the values of the items in the collection are read-only and cannot be changed.
public bool AreItemsReadOnly { get; }
Property Value
- Boolean:
true
if the values of the items in the collection are read-only and cannot be changed; otherwise,false
.
IsCollectionReadOnly
Gets whether items can be added to or removed from the collection.
public bool IsCollectionReadOnly { get; }
Property Value
- Boolean:
true
if items can be added to or removed from the collection; otherwise,false
.
MultipleItemsFormat
Gets or sets the format for text to return when there are multiple items.
public string MultipleItemsFormat { get; set; }
Property Value
- String:
The format for text to return when there are multiple items. The default value is "{0} items".
NoItemsText
Gets or sets the text to return when there are no items.
public string NoItemsText { get; set; }
Property Value
- String:
The text to return when there are no items. The default value is "No items".
OneItemText
Gets or sets the text to return when there is one item.
public string OneItemText { get; set; }
Property Value
- String:
The text to return when there is one item. The default value is "1 item".
Methods
AddItem(IPropertyModel, Object)
Adds the specified item into to the collection.
public virtual bool AddItem(IPropertyModel propertyModel, object item)
Parameter | Type | Description |
---|---|---|
propertyModel | IPropertyModel | The IPropertyModel associated with the collection. |
item | Object | The item that should be added. |
Returns
- Boolean:
true
if the item was added to the collection; otherwise,false
.
CanAddItem(IPropertyModel)
Gets a value indicating whether a new item can be added to the collection.
public virtual bool CanAddItem(IPropertyModel propertyModel)
Parameter | Type | Description |
---|---|---|
propertyModel | IPropertyModel | The IPropertyModel associated with the collection. |
Returns
- Boolean:
true
if a new item can be added to the collection; otherwise,false
.
CanConvertTo(ITypeDescriptorContext, Type)
Returns whether this converter can convert the object to the specified type, using the specified context.
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
Parameter | Type | Description |
---|---|---|
context | ITypeDescriptorContext | An |
destinationType | Type | A |
Returns
- Boolean:
true
if this converter can perform the conversion; otherwise,false
.
ConvertTo(ITypeDescriptorContext, CultureInfo, Object, Type)
Converts the given value object to the specified type, using the specified context and culture information.
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
Parameter | Type | Description |
---|---|---|
context | ITypeDescriptorContext | An |
culture | CultureInfo | A |
value | Object | The |
destinationType | Type | The |
Returns
- Object:
An
Object
that represents the converted value.
CreateCollectionItemPropertyDescriptor(ITypeDescriptorContext, Attribute[], ICollection, Int32, Object, Type)
Creates an instance of PropertyDescriptor for the collection item.
protected virtual PropertyDescriptor CreateCollectionItemPropertyDescriptor(ITypeDescriptorContext context, Attribute[] attributes, ICollection collection, int index, object item, Type itemType)
Parameter | Type | Description |
---|---|---|
context | ITypeDescriptorContext | An ITypeDescriptorContext that provides a format context. |
attributes | Attribute[] | An array of type Attribute that will be used as a filter. |
collection | ICollection | The collection that contains the item. |
index | Int32 | The index of the item in the collection. |
item | Object | The item in the collection. |
itemType | Type | Type of the item. |
Returns
- PropertyDescriptor:
An instance of PropertyDescriptor for the collection item.
CreateDictionaryItemPropertyDescriptor(ITypeDescriptorContext, Attribute[], IDictionary, Object, Type)
Creates an instance of PropertyDescriptor for the dictionary item.
protected virtual PropertyDescriptor CreateDictionaryItemPropertyDescriptor(ITypeDescriptorContext context, Attribute[] attributes, IDictionary dictionary, object key, Type itemType)
Parameter | Type | Description |
---|---|---|
context | ITypeDescriptorContext | An ITypeDescriptorContext that provides a format context. |
attributes | Attribute[] | An array of type Attribute that will be used as a filter. |
dictionary | IDictionary | The dictionary that contains the item. |
key | Object | The key of the item in the dictionary. |
itemType | Type | Type of the item. |
Returns
- PropertyDescriptor:
An instance of PropertyDescriptor for the dictionary item.
CreateItem(IPropertyModel)
Creates a new item that can be added into to the collection.
public virtual object CreateItem(IPropertyModel propertyModel)
Parameter | Type | Description |
---|---|---|
propertyModel | IPropertyModel | The IPropertyModel associated with the collection. |
Returns
- Object:
The item that was created.
CreateListItemPropertyDescriptor(ITypeDescriptorContext, Attribute[], IList, Int32, Type)
Creates an instance of PropertyDescriptor for the list item.
protected virtual PropertyDescriptor CreateListItemPropertyDescriptor(ITypeDescriptorContext context, Attribute[] attributes, IList list, int index, Type itemType)
Parameter | Type | Description |
---|---|---|
context | ITypeDescriptorContext | An ITypeDescriptorContext that provides a format context. |
attributes | Attribute[] | An array of type Attribute that will be used as a filter. |
list | IList | The list that contains the item. |
index | Int32 | The index of the item in the list. |
itemType | Type | Type of the item. |
Returns
- PropertyDescriptor:
An instance of PropertyDescriptor for the list item.
GetCollectionProperties(ITypeDescriptorContext, Attribute[], ICollection)
Gets a collection of properties for the specified collection using the specified context and attributes.
protected virtual PropertyDescriptor[] GetCollectionProperties(ITypeDescriptorContext context, Attribute[] attributes, ICollection collection)
Parameter | Type | Description |
---|---|---|
context | ITypeDescriptorContext | An ITypeDescriptorContext that provides a format context. |
attributes | Attribute[] | An array of type Attribute that will be used as a filter. |
collection | ICollection | The collection whose properties should be returned. |
Returns
- PropertyDescriptor[]:
A PropertyDescriptor array with the properties associated with the specified collection, or null if there are no properties.
GetDictionaryProperties(ITypeDescriptorContext, Attribute[], IDictionary)
Gets a collection of properties for the specified dictionary using the specified context and attributes.
protected virtual PropertyDescriptor[] GetDictionaryProperties(ITypeDescriptorContext context, Attribute[] attributes, IDictionary dictionary)
Parameter | Type | Description |
---|---|---|
context | ITypeDescriptorContext | An ITypeDescriptorContext that provides a format context. |
attributes | Attribute[] | An array of type Attribute that will be used as a filter. |
dictionary | IDictionary | The dictionary whose properties should be returned. |
Returns
- PropertyDescriptor[]:
A PropertyDescriptor array with the properties associated with the specified dictionary, or null if there are no properties.
GetListProperties(ITypeDescriptorContext, Attribute[], IList)
Gets a collection of properties for the specified list using the specified context and attributes.
protected virtual PropertyDescriptor[] GetListProperties(ITypeDescriptorContext context, Attribute[] attributes, IList list)
Parameter | Type | Description |
---|---|---|
context | ITypeDescriptorContext | An ITypeDescriptorContext that provides a format context. |
attributes | Attribute[] | An array of type Attribute that will be used as a filter. |
list | IList | The list whose properties should be returned. |
Returns
- PropertyDescriptor[]:
A PropertyDescriptor array with the properties associated with the specified list, or null if there are no properties.
GetProperties(ITypeDescriptorContext, Object, Attribute[])
Gets a collection of properties for the value using the specified context and attributes.
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
Parameter | Type | Description |
---|---|---|
context | ITypeDescriptorContext | An ITypeDescriptorContext that provides a format context. |
value | Object | An Object that specifies the type to get the properties for. |
attributes | Attribute[] | An array of type Attribute that will be used as a filter. |
Returns
- PropertyDescriptorCollection:
A PropertyDescriptorCollection with the properties that are exposed for this data type, or null if there are no properties.
GetPropertiesSupported(ITypeDescriptorContext)
Gets a value indicating whether this object supports properties.
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
Parameter | Type | Description |
---|---|---|
context | ITypeDescriptorContext | An ITypeDescriptorContext that provides a format context. |
Returns
- Boolean:
true
if properties are supported; otherwise,false
.
Remarks
The default method implementation always returns true
since child items should be accessible as nested properties.