Table of Contents

Class ItemsSourceBase<T>

Namespace
Ecng.ComponentModel
Assembly
Ecng.ComponentModel.dll

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

public class ItemsSourceBase<T> : IItemsSource<T>, IItemsSource

Type Parameters

T

The type of the values in the source.

Inheritance
ItemsSourceBase<T>
Implements
Derived
Inherited Members
Extension Methods

Constructors

ItemsSourceBase()

Initializes a new instance of the ItemsSourceBase<T> class.

public ItemsSourceBase()

ItemsSourceBase(bool, ListSortDirection?, Func<IItemsSourceItem, bool>, Func<T, string>, Func<T, string>)

Initializes a new instance of the ItemsSourceBase<T> class.

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

Parameters

excludeObsolete bool

A value indicating whether obsolete items should be excluded.

sortOrder ListSortDirection?

The sort order for the items.

filter Func<IItemsSourceItem, bool>

A filter function to apply on items.

getName Func<T, string>

A function to retrieve the display name from a value.

getDescription Func<T, string>

A function to retrieve the description from a value.

ItemsSourceBase(IEnumerable, bool, ListSortDirection?, Func<IItemsSourceItem, bool>, Func<T, string>, Func<T, string>)

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

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

Parameters

values IEnumerable

The collection of values or items.

excludeObsolete bool

A value indicating whether obsolete items should be excluded.

sortOrder ListSortDirection?

The sort order for the items.

filter Func<IItemsSourceItem, bool>

A filter function to apply on items.

getName Func<T, string>

A function to retrieve the display name from a value.

getDescription Func<T, string>

A function to retrieve the description from a value.

ItemsSourceBase(IEnumerable, Func<T, string>, Func<T, string>)

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

public ItemsSourceBase(IEnumerable values, Func<T, string> getName = null, Func<T, string> getDescription = null)

Parameters

values IEnumerable

The collection of values or items.

getName Func<T, string>

A function to retrieve the display name from a value.

getDescription Func<T, string>

A function to retrieve the description from a value.

Properties

ExcludeObsolete

Gets a value indicating whether obsolete items should be excluded.

public bool ExcludeObsolete { get; }

Property Value

bool

Format

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

protected virtual string Format { get; }

Property Value

string

SortOrder

Gets the sort order for sorting the items.

public ListSortDirection? SortOrder { get; }

Property Value

ListSortDirection?

ValueType

Gets the type of the value.

public virtual Type ValueType { get; }

Property Value

Type

Values

Gets the collection of strongly typed items.

public IEnumerable<IItemsSourceItem<T>> Values { get; }

Property Value

IEnumerable<IItemsSourceItem<T>>

Methods

CreateNewItem(T)

Creates a new item with the specified value.

public virtual IItemsSourceItem<T> CreateNewItem(T value)

Parameters

value T

The value for the new item.

Returns

IItemsSourceItem<T>

The newly created item.

Filter(IItemsSourceItem<T>)

Applies filtering to the given item.

protected virtual bool Filter(IItemsSourceItem<T> item)

Parameters

item IItemsSourceItem<T>

The item to filter.

Returns

bool

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

GetDescription(T)

Retrieves the description for the specified value.

protected virtual string GetDescription(T value)

Parameters

value T

The value whose description is to be retrieved.

Returns

string

The description.

GetIcon(T)

Retrieves the icon for the specified value.

protected virtual Uri GetIcon(T value)

Parameters

value T

The value whose icon is to be retrieved.

Returns

Uri

The icon URI.

GetIsObsolete(T)

Determines whether the specified value is marked as obsolete.

protected virtual bool GetIsObsolete(T value)

Parameters

value T

The value to check.

Returns

bool

true if obsolete; otherwise, false.

GetName(T)

Retrieves the display name for the specified value.

protected virtual string GetName(T value)

Parameters

value T

The value whose display name is to be retrieved.

Returns

string

The display name.

GetValues()

Retrieves the underlying collection of values.

protected virtual IEnumerable<T> GetValues()

Returns

IEnumerable<T>

The collection of values.