Class PersistableCollection<T>
This collection class supports persistence of generic items.
Inheritance
Implements
Inherited Members
Namespace: MESL.SqlRace.Domain.Collections
Assembly: MESL.SqlRace.Domain.dll
Syntax
public class PersistableCollection<T> : SynchronizedList<T>, IList, ICollection, IPersistableCollectionInternal<T>, IPersistableCollection<T>, IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable where T : EntityBase
Type Parameters
Name | Description |
---|---|
T | Type of object in collection |
Remarks
When each of the methods in this collection is called, the T data is persisted to the SQL Race data store immediately.
Methods
Add(IEnumerable<T>)
A collection that can be persisted to and underlying data store.
Declaration
public override void Add(IEnumerable<T> elements)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | elements |
Overrides
AddNoRepository(T)
Adds the item without modifying the repository.
Declaration
protected virtual void AddNoRepository(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item. |
Clear()
Clears all items from the collection
Declaration
public void Clear()
ClearItems()
Clears the items.
Declaration
protected override void ClearItems()
Overrides
InitialAddItems(IEnumerable<T>)
This is used as part of initialization of the collection by adding in the items. This will add the items using the AddNoRepository method call.
Declaration
protected void InitialAddItems(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items |
InsertItem(Int32, T)
Inserts the item.
Declaration
protected override void InsertItem(int index, T newItem)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index. |
T | newItem | The new item. |
Overrides
Overwrite(T, Predicate<T>)
Overwrites first matching item with the specified item, else adds item to collection.
Declaration
public bool Overwrite(T item, Predicate<T> func)
Parameters
Type | Name | Description |
---|---|---|
T | item | The new item. |
System.Predicate<T> | func | The predicate func. |
Returns
Type | Description |
---|---|
System.Boolean | True if item was overwritten |
PublishAddedEvent(T)
Publishes the added event.
Declaration
protected virtual void PublishAddedEvent(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The added item. |
PublishRemovedEvent(T)
Publishes the removed event.
Declaration
protected virtual void PublishRemovedEvent(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The removed item. |
RemoveAll(Predicate<T>)
Removes all items matching predicate.
Declaration
public bool RemoveAll(Predicate<T> func)
Parameters
Type | Name | Description |
---|---|---|
System.Predicate<T> | func | The predicate func. |
Returns
Type | Description |
---|---|
System.Boolean | True if items were removed |
RemoveItem(Int32)
Removes the item.
Declaration
protected override void RemoveItem(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index. |
Overrides
RemoveNoRepository(T)
Removes the item without modifying the repository.
Declaration
protected virtual void RemoveNoRepository(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item. |
SetItem(Int32, T)
Sets the item.
Declaration
protected override void SetItem(int index, T newItem)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index. |
T | newItem | The new item. |
Overrides
Events
ItemAdded
Event fired when an item is added to the collection
Declaration
public event EventHandler<ItemEventArgs> ItemAdded
Event Type
Type | Description |
---|---|
System.EventHandler<ItemEventArgs> |
ItemRemoved
Event fired when an item is removed from the collection
Declaration
public event EventHandler<ItemEventArgs> ItemRemoved
Event Type
Type | Description |
---|---|
System.EventHandler<ItemEventArgs> |