Class ObservableList<T>
An implementation of IList<T>
which fires INotifyCollectionChanged
and INotifyPropertyChanged when required. This allows the list to be used as
a data source for WPF user controls implementing data-binding.
Inherited Members
Namespace: Sdl.FileTypeSupport.Framework.Core.Settings
Assembly: Sdl.FileTypeSupport.Framework.Core.Settings.dll
Syntax
public class ObservableList<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged
Type Parameters
Name | Description |
---|---|
T | The type of object contained in the list. |
Constructors
ObservableList()
Default constructor creating a new empty list with a default capacity.
Declaration
public ObservableList()
ObservableList(IEnumerable<T>)
Constructor which takes a collection of T and adds it to this list
Declaration
public ObservableList(IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | The collection to be added |
Properties
Count
The number of elements contained in the list.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
IsReadOnly
Determines whether the list is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
bool |
this[int]
Retrieves the list item at the specified index.
Declaration
public T this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index of the item to retrieve. |
Property Value
Type | Description |
---|---|
T | The item located at the index. |
Methods
Add(T)
Adds an item to the list.
Declaration
public void Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to add to the list. |
AddRange(IEnumerable<T>)
Adds the elements of the specified collection to the list.
Declaration
public void AddRange(IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | The collection of elements to add to the list. |
Clear()
Removes all items from the list.
Declaration
public void Clear()
ClearListItemSettings(ISettingsGroup, string)
Removes all saved items belonging to this list from the stored settings group. This is called from SaveToSettingsGroup(ISettingsGroup, string) to make sure that the settings being updated are all saved cleanly.
Declaration
public virtual void ClearListItemSettings(ISettingsGroup settingsGroup, string listSettingId)
Parameters
Type | Name | Description |
---|---|---|
ISettingsGroup | settingsGroup | The settings group to remove the settings from. |
string | listSettingId | The ID of the setting to remove. |
Contains(T)
Determines whether the list contains a specific item.
Declaration
public bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to search the list for. |
Returns
Type | Description |
---|---|
bool |
|
CopyTo(T[], int)
Copies the elements of the list to an array, starting at a particular index.
Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array to copy the list items in to. |
int | arrayIndex | The zero-based index of the array from which to start copying. |
CreateObservableStringList(string[])
Factory method used by the Spring framework to create observable string lists to assign to the properties that require them.
Declaration
public static ObservableList<string> CreateObservableStringList(string[] strings)
Parameters
Type | Name | Description |
---|---|---|
string[] | strings |
Returns
Type | Description |
---|---|
ObservableList<string> |
Equals(object)
Determines whether the given object is equal to this object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | given object |
Returns
Type | Description |
---|---|
bool | whether equal to this object |
Overrides
Find(Predicate<T>)
Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire ObservableList.
Declaration
public T Find(Predicate<T> match)
Parameters
Type | Name | Description |
---|---|---|
Predicate<T> | match | The Predicate<T> delegate that defines the conditions of the element to search for. |
Returns
Type | Description |
---|---|
T | The first element that matches the conditions defined by the specified predicate, if found; otherwise, the default value for type T. |
GetEnumerator()
Returns an enumerator that iterates through the list.
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<T> | An enumerator that iterates through the list. |
GetHashCode()
Gets the hash code.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | hash code |
Overrides
GetListItemFromSettings(ISettingsGroup, string, out bool)
Gets the setting for the list item from the settings group and populates it.
Declaration
protected virtual T GetListItemFromSettings(ISettingsGroup settingsGroup, string listItemSetting, out bool foundSetting)
Parameters
Type | Name | Description |
---|---|---|
ISettingsGroup | settingsGroup | The settings group containing the list item settings. |
string | listItemSetting | The setting ID to use to retrieve the setting. |
bool | foundSetting | A flag which reports if the setting was found or not. |
Returns
Type | Description |
---|---|
T | The populated list item. |
IndexOf(T)
Determines the index of the specified item in the list.
Declaration
public int IndexOf(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to locate in the list. |
Returns
Type | Description |
---|---|
int | The zero-based index of the item in the list. |
Insert(int, T)
Inserts an item into the list at the specified index.
Declaration
public void Insert(int index, T item)
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index to insert the item at. |
T | item | The item to insert into the list. |
InsertRange(int, IEnumerable<T>)
Inserts the elements of a collection into list at the specified index.
Declaration
public void InsertRange(int index, IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index to insert elements at. |
IEnumerable<T> | collection | The elements to insert into the list. |
PopulateFromSettingsGroup(ISettingsGroup, string)
Restores the list from the settings group and populates itself using the setting ID as its base.
Declaration
public virtual void PopulateFromSettingsGroup(ISettingsGroup settingsGroup, string listSettingId)
Parameters
Type | Name | Description |
---|---|---|
ISettingsGroup | settingsGroup | The settings group to load from. |
string | listSettingId | The setting ID to use as a base when populating the list. |
Remove(T)
Removes the first occurrence of a specific item from the list.
Declaration
public bool Remove(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to remove. |
Returns
Type | Description |
---|---|
bool |
|
RemoveAt(int)
Removes the list item at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index of the item to remove. |
SaveToSettingsGroup(ISettingsGroup, string)
Saves this list to the settings group using the setting ID as a base.
Declaration
public virtual void SaveToSettingsGroup(ISettingsGroup settingsGroup, string listSettingId)
Parameters
Type | Name | Description |
---|---|---|
ISettingsGroup | settingsGroup | The settings group to save to. |
string | listSettingId | The setting ID to use as a base when saving the list. |
Sort()
Sorts the list using the default comparer.
Declaration
public void Sort()
Sort(IComparer<T>)
Sorts the list using the provided comparer.
Declaration
public void Sort(IComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
IComparer<T> | comparer | The comparer to sort the list with. |
Sort(Comparison<T>)
Sorts the list using the provided comparison delegate
Declaration
public void Sort(Comparison<T> comparison)
Parameters
Type | Name | Description |
---|---|---|
Comparison<T> | comparison | The delegate to use when comparing |
ToArray()
Copies the elements of the list to a new array.
Declaration
public T[] ToArray()
Returns
Type | Description |
---|---|
T[] | A new array containing the elements of the list. |
Events
CollectionChanged
Event that is fired whenever the list collection has changed.
Declaration
public event NotifyCollectionChangedEventHandler CollectionChanged
Event Type
Type | Description |
---|---|
NotifyCollectionChangedEventHandler |
PropertyChanged
Event that is fired whenever the value of a property on the list has changed.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type | Description |
---|---|
PropertyChangedEventHandler |