Class
NamedObjects<T>

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:

cs-api-definition
public class NamedObjects<T> : IEnumerable where T : INamedObject

Inheritance: objectNamedObjects<T>

Implements: IEnumerable

Constructors

NamedObjects()

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

Declaration

cs-api-definition
public NamedObjects()

Properties

Count

Gets the total number of items in the collection.

Declaration

cs-api-definition
public int Count { get; }

Property Value

int

The count.

this[int]

Gets the INamedObject at the specified index.

Declaration

cs-api-definition
public T this[int index] { get; }

Parameters

index

int

The index of the desired element.

Property Value

T

The item at specified index.

Methods

Add(T)

Adds the specified item.

Declaration

cs-api-definition
public void Add(T item)

Parameters

item

T

The new item.

AddRange(IEnumerable<T>)

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

Declaration

cs-api-definition
public void AddRange(IEnumerable<T> items)

Parameters

items

IEnumerable<T>

The range of items.

Clear()

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

Declaration

cs-api-definition
public void Clear()

Contains(T)

Determines whether the specified item is contained in the collection.

Declaration

cs-api-definition
public bool Contains(T item)

Parameters

item

T

The searched item.

Returns

bool

True if contained.

Contains(string)

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

Declaration

cs-api-definition
public bool Contains(string name)

Parameters

name

string

The name of the searched item.

Returns

bool

True if contained.

GetByName(string)

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

Declaration

cs-api-definition
public T GetByName(string name)

Parameters

name

string

The name of the searched item.

Returns

T

The searched item.

GetEnumerator()

Returns an enumerator that iterates through the collection.

Declaration

cs-api-definition
public IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>

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

OnChanged()

Called when the collection is changed.

Declaration

cs-api-definition
protected virtual void OnChanged()

OnItemReplaced(NamedObjectsItemReplaceEventArgs)

Raises the event.

Declaration

cs-api-definition
protected virtual void OnItemReplaced(NamedObjectsItemReplaceEventArgs args)

Parameters

args

NamedObjectsItemReplaceEventArgs

The NamedObjectsItemReplaceEventArgs instance containing the event data.

Remove(string)

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

Declaration

cs-api-definition
public void Remove(string name)

Parameters

name

string

The name of the item.

Replace(string, T)

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

Declaration

cs-api-definition
public void Replace(string itemName, T item)

Parameters

itemName

string

Name of the item to replace.

item

T

The item to replace with.

TryGetByName(string, out T)

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

Declaration

cs-api-definition
public bool TryGetByName(string name, out T result)

Parameters

name

string

The name of the searched item.

result

T

The result.

Returns

bool

True if succeed.

Events

Changed

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

Declaration

cs-api-definition
public event EventHandler Changed

Event Value

EventHandler

ItemReplaced

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

Declaration

cs-api-definition
public event EventHandler<NamedObjectsItemReplaceEventArgs> ItemReplaced

Event Value

EventHandler<NamedObjectsItemReplaceEventArgs>