In This Article

ExpandableCollectionConverter Class

Represents a type converter that is capable of expanding various collection types.

public class ExpandableCollectionConverter : TypeConverter, ICollectionTypeConverter
Inheritance:
System.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 System.Boolean

Whether items can be added to or removed from the collection.

areItemsReadOnly System.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

System.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

System.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

System.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

System.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

System.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 System.Object

The item that should be added.

Returns

System.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

System.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 System.ComponentModel.ITypeDescriptorContext

An ITypeDescriptorContext that provides a format context.

destinationType System.Type

A Type that represents the type you want to convert to.

Returns

System.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 System.ComponentModel.ITypeDescriptorContext

An ITypeDescriptorContext that provides a format context.

culture System.Globalization.CultureInfo

A CultureInfo object. If null is passed, the current culture is assumed.

value System.Object

The Object to convert.

destinationType System.Type

The Type to convert the value parameter to.

Returns

System.Object:

An Object that represents the converted value.

CreateCollectionItemPropertyDescriptor(ITypeDescriptorContext, Attribute[], ICollection, Int32, Object, Type)

Creates an instance of System.ComponentModel.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 System.ComponentModel.ITypeDescriptorContext

An System.ComponentModel.ITypeDescriptorContext that provides a format context.

attributes Attribute[]

An array of type Attribute that will be used as a filter.

collection System.Collections.ICollection

The collection that contains the item.

index System.Int32

The index of the item in the collection.

item System.Object

The item in the collection.

itemType System.Type

Type of the item.

Returns

System.ComponentModel.PropertyDescriptor:

An instance of System.ComponentModel.PropertyDescriptor for the collection item.

CreateDictionaryItemPropertyDescriptor(ITypeDescriptorContext, Attribute[], IDictionary, Object, Type)

Creates an instance of System.ComponentModel.PropertyDescriptor for the dictionary item.

protected virtual PropertyDescriptor CreateDictionaryItemPropertyDescriptor(ITypeDescriptorContext context, Attribute[] attributes, IDictionary dictionary, object key, Type itemType)
Parameter Type Description
context System.ComponentModel.ITypeDescriptorContext

An System.ComponentModel.ITypeDescriptorContext that provides a format context.

attributes Attribute[]

An array of type Attribute that will be used as a filter.

dictionary System.Collections.IDictionary

The dictionary that contains the item.

key System.Object

The key of the item in the dictionary.

itemType System.Type

Type of the item.

Returns

System.ComponentModel.PropertyDescriptor:

An instance of System.ComponentModel.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

System.Object:

The item that was created.

CreateListItemPropertyDescriptor(ITypeDescriptorContext, Attribute[], IList, Int32, Type)

Creates an instance of System.ComponentModel.PropertyDescriptor for the list item.

protected virtual PropertyDescriptor CreateListItemPropertyDescriptor(ITypeDescriptorContext context, Attribute[] attributes, IList list, int index, Type itemType)
Parameter Type Description
context System.ComponentModel.ITypeDescriptorContext

An System.ComponentModel.ITypeDescriptorContext that provides a format context.

attributes Attribute[]

An array of type Attribute that will be used as a filter.

list System.Collections.IList

The list that contains the item.

index System.Int32

The index of the item in the list.

itemType System.Type

Type of the item.

Returns

System.ComponentModel.PropertyDescriptor:

An instance of System.ComponentModel.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 System.ComponentModel.ITypeDescriptorContext

An System.ComponentModel.ITypeDescriptorContext that provides a format context.

attributes Attribute[]

An array of type Attribute that will be used as a filter.

collection System.Collections.ICollection

The collection whose properties should be returned.

Returns

System.ComponentModel.PropertyDescriptor[]:

A System.ComponentModel.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 System.ComponentModel.ITypeDescriptorContext

An System.ComponentModel.ITypeDescriptorContext that provides a format context.

attributes Attribute[]

An array of type Attribute that will be used as a filter.

dictionary System.Collections.IDictionary

The dictionary whose properties should be returned.

Returns

System.ComponentModel.PropertyDescriptor[]:

A System.ComponentModel.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 System.ComponentModel.ITypeDescriptorContext

An System.ComponentModel.ITypeDescriptorContext that provides a format context.

attributes Attribute[]

An array of type Attribute that will be used as a filter.

list System.Collections.IList

The list whose properties should be returned.

Returns

System.ComponentModel.PropertyDescriptor[]:

A System.ComponentModel.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 System.ComponentModel.ITypeDescriptorContext

An System.ComponentModel.ITypeDescriptorContext that provides a format context.

value System.Object

An System.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

System.ComponentModel.PropertyDescriptorCollection:

A System.ComponentModel.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 System.ComponentModel.ITypeDescriptorContext

An System.ComponentModel.ITypeDescriptorContext that provides a format context.

Returns

System.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.