ItemsSourceBase

Ecng.ComponentModel

Represents the base implementation for an items source containing values of type .

Implements: IItemsSource<T>, IItemsSource

Constructors

ItemsSourceBase
public ItemsSourceBase(bool excludeObsolete, ListSortDirection? sortOrder, Func<IItemsSourceItem, bool> filter, Func<T, string> getName, Func<T, string> getDescription)
itemsSourceBase = ItemsSourceBase(excludeObsolete, sortOrder, filter, getName, getDescription)

Initializes a new instance of the ItemsSourceBase class.

excludeObsolete
A value indicating whether obsolete items should be excluded.
sortOrder
The sort order for the items.
filter
A filter function to apply on items.
getName
A function to retrieve the display name from a value.
getDescription
A function to retrieve the description from a value.
ItemsSourceBase
public ItemsSourceBase(IEnumerable values, bool excludeObsolete, ListSortDirection? sortOrder, Func<IItemsSourceItem, bool> filter, Func<T, string> getName, Func<T, string> getDescription)
itemsSourceBase = ItemsSourceBase(values, excludeObsolete, sortOrder, filter, getName, getDescription)

Initializes a new instance of the ItemsSourceBase class using the specified values.

values
The collection of values or items.
excludeObsolete
A value indicating whether obsolete items should be excluded.
sortOrder
The sort order for the items.
filter
A filter function to apply on items.
getName
A function to retrieve the display name from a value.
getDescription
A function to retrieve the description from a value.
ItemsSourceBase
public ItemsSourceBase(IEnumerable values, Func<T, string> getName, Func<T, string> getDescription)
itemsSourceBase = ItemsSourceBase(values, getName, getDescription)

Initializes a new instance of the ItemsSourceBase class using a collection of values.

values
The collection of values or items.
getName
A function to retrieve the display name from a value.
getDescription
A function to retrieve the description from a value.
ItemsSourceBase
public ItemsSourceBase()
itemsSourceBase = ItemsSourceBase()

Initializes a new instance of the ItemsSourceBase class.

Properties

Ecng#ComponentModel#IItemsSource#Values

Gets the collection of items.

ExcludeObsolete
public bool ExcludeObsolete { get; }
value = itemsSourceBase.ExcludeObsolete

Gets a value indicating whether obsolete items should be excluded.

Format
protected virtual string Format { get; }
value = itemsSourceBase.Format

Gets the format string for displaying the value. Override to provide a custom format.

SortOrder
public ListSortDirection? SortOrder { get; }
value = itemsSourceBase.SortOrder

Gets the sort order for sorting the items.

Values
public IEnumerable<IItemsSourceItem<T>> Values { get; }
value = itemsSourceBase.Values

Gets the collection of strongly typed items.

ValueType
public virtual Type ValueType { get; }
value = itemsSourceBase.ValueType

Gets the type of the value.

Methods

CreateNewItem
public virtual IItemsSourceItem<T> CreateNewItem(T value)
result = itemsSourceBase.CreateNewItem(value)

Creates a new item with the specified value.

value
The value for the new item.

Returns: The newly created item.

Filter
protected virtual bool Filter(IItemsSourceItem<T> item)
result = itemsSourceBase.Filter(item)

Applies filtering to the given item.

item
The item to filter.

Returns: true if the item should be included; otherwise, false.

GetDescription
protected virtual string GetDescription(T value)
result = itemsSourceBase.GetDescription(value)

Retrieves the description for the specified value.

value
The value whose description is to be retrieved.

Returns: The description.

GetIcon
protected virtual Uri GetIcon(T value)
result = itemsSourceBase.GetIcon(value)

Retrieves the icon for the specified value.

value
The value whose icon is to be retrieved.

Returns: The icon URI.

GetIsObsolete
protected virtual bool GetIsObsolete(T value)
result = itemsSourceBase.GetIsObsolete(value)

Determines whether the specified value is marked as obsolete.

value
The value to check.

Returns: true if obsolete; otherwise, false.

GetName
protected virtual string GetName(T value)
result = itemsSourceBase.GetName(value)

Retrieves the display name for the specified value.

value
The value whose display name is to be retrieved.

Returns: The display name.

GetValues
protected virtual IEnumerable<T> GetValues()
result = itemsSourceBase.GetValues()

Retrieves the underlying collection of values.

Returns: The collection of values.