New to Telerik UI for WinFormsStart a free 30-day trial

Provides a dictionary-based collection of named objects with change notification and item replacement events.

Definition

Namespace:Telerik.Windows.Documents.Spreadsheet.Core

Assembly:Telerik.Windows.Documents.Spreadsheet.dll

Type Parameters:

T

The type of the T.

Syntax:

C#
public class NamedObjects<T> : IEnumerable where T : INamedObject

Inheritance: objectNamedObjects<T>

Implements: IEnumerable

Constructors

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

C#
public NamedObjects()

Properties

Gets the total number of items in the collection.

C#
public int Count { get; }
Property Value:

The count.

Gets the INamedObject at the specified index.

C#
public T this[int index] { get; }
Parameters:indexint

The index of the desired element.

Property Value:

The item at specified index.

Methods

Adds the specified item.

C#
public void Add(T item)
Parameters:itemT

The new item.

Adds multiple items to the collection in a single update scope, raising Changed once after all additions.

C#
public void AddRange(IEnumerable<T> items)
Parameters:itemsIEnumerable<T>

The range of items.

Removes all items from the collection and raises the Changed event.

C#
public void Clear()

Determines whether item with the specified name is contained in the collection.

C#
public bool Contains(string name)
Parameters:namestring

The name of the searched item.

Returns:

bool

True if contained.

Determines whether the specified item is contained in the collection.

C#
public bool Contains(T item)
Parameters:itemT

The searched item.

Returns:

bool

True if contained.

Retrieves the item with the specified name, throwing an exception if not found.

C#
public T GetByName(string name)
Parameters:namestring

The name of the searched item.

Returns:

T

The searched item.

Returns an enumerator that iterates through the collection.

C#
public IEnumerator<T> GetEnumerator()
Returns:

IEnumerator<T>

A IEnumerator<T> that can be used to iterate through the collection.

Called when the collection is changed.

C#
protected virtual void OnChanged()

Raises the event.

C#
protected virtual void OnItemReplaced(NamedObjectsItemReplaceEventArgs args)
Parameters:argsNamedObjectsItemReplaceEventArgs

The NamedObjectsItemReplaceEventArgs instance containing the event data.

Removes the item with the specified name from the collection and raises the Changed event.

C#
public void Remove(string name)
Parameters:namestring

The name of the item.

Replaces the item with the specified name with a new item, raising ItemReplaced and Changed events.

C#
public void Replace(string itemName, T item)
Parameters:itemNamestring

Name of the item to replace.

itemT

The item to replace with.

Attempts to retrieve the item with the specified name without throwing an exception if not found.

C#
public bool TryGetByName(string name, out T result)
Parameters:namestring

The name of the searched item.

resultT

The result.

Returns:

bool

True if succeed.

Events

Raised after items are added, removed, or cleared, unless change events are suspended.

C#
public event EventHandler Changed

Raised when an item is replaced via the Replace method, providing old and new item names.

C#
public event EventHandler<NamedObjectsItemReplaceEventArgs> ItemReplaced