Class StatefulCollection<T>
Collection which handles internal a list of: new, not changed and deleted items.
Inheritance
Implements
Inherited Members
Namespace: Simplic.Collections.Generic
Assembly: Simplic.CoreLib.dll
Syntax
public class StatefulCollection<T> : ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
Name | Description |
---|---|
T | Item type |
Constructors
| Improve this Doc View SourceStatefulCollection(IEnumerable<T>)
Initialize new stateful iterable
Declaration
public StatefulCollection(IEnumerable<T> initialList)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | initialList | Initial list of items |
Properties
| Improve this Doc View SourceCount
Gets the amount of items (new and current items)
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
CountNewItems
Get the amount of new items
Declaration
public int CountNewItems { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
CountRemovedItems
Gets the amount of removed items
Declaration
public int CountRemovedItems { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsReadOnly
Gets whether the current collection is readonly or not
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceAdd(T)
Add a new item. If the item already exists - ignore it If the item was removed, put it in the item list again
Declaration
public void Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to add |
AddRange(IEnumerable<T>)
Add a range of items. Each item will be handled as described for Add(T)
Declaration
public void AddRange(IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | collection |
Clear()
Clear the howle collection
Declaration
public void Clear()
Commit()
Cleares the to remove list and add all items from new item to items
Declaration
public void Commit()
Contains(T)
Check whether an items exists in the items list or the new items list
Declaration
public bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to proof |
Returns
Type | Description |
---|---|
System.Boolean | True if the item exists |
CopyTo(T[], Int32)
Copy current items into an array
Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | Array to copy items to |
System.Int32 | arrayIndex | Start index |
GetAsObservableCollection()
Shows a preview of the commited collection data
Declaration
public ObservableCollection<T> GetAsObservableCollection()
Returns
Type | Description |
---|---|
System.Collections.ObjectModel.ObservableCollection<T> | data after a possible commit |
GetEnumerator()
Get enumerator for the list of items and new items
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<T> | Returns an instance of an enumerator |
GetItems()
Enumerator to all comitted items
Declaration
public IEnumerable<T> GetItems()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | Enumerable of comitted items |
GetNewItems()
Enumerator to iteratore over all new items
Declaration
public IEnumerable<T> GetNewItems()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | Enumerable of new items |
GetRemovedItems()
Enumerator to iteratore over all removed items
Declaration
public IEnumerable<T> GetRemovedItems()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | Enumerable of removed items |
MarkAllAsRemoved()
Mark all items in the items list as removed and put them in the removed list
Declaration
public void MarkAllAsRemoved()
Remove(T)
Remove an item and put it into the removed items list
Declaration
public bool Remove(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to remove |
Returns
Type | Description |
---|---|
System.Boolean | True if the item was removed, false if not |
Events
| Improve this Doc View SourceAddItem
On add item event
Declaration
public event StatefulCollection<T>.AddItemEventHandler AddItem
Event Type
Type | Description |
---|---|
StatefulCollection.AddItemEventHandler<> |
ClearCollection
On clear collection event
Declaration
public event StatefulCollection<T>.ClearCollectionEventHandlder ClearCollection
Event Type
Type | Description |
---|---|
StatefulCollection.ClearCollectionEventHandlder<> |
CollectionCleared
On item cleared event
Declaration
public event StatefulCollection<T>.CollectionClearedEventHandlder CollectionCleared
Event Type
Type | Description |
---|---|
StatefulCollection.CollectionClearedEventHandlder<> |
CollectionCommitted
On collection committed event
Declaration
public event StatefulCollection<T>.CollectionCommittedEventHandlder CollectionCommitted
Event Type
Type | Description |
---|---|
StatefulCollection.CollectionCommittedEventHandlder<> |
CommitCollection
On commit collection event
Declaration
public event StatefulCollection<T>.CommitCollectionEventHandlder CommitCollection
Event Type
Type | Description |
---|---|
StatefulCollection.CommitCollectionEventHandlder<> |
ItemAdded
On item added event
Declaration
public event StatefulCollection<T>.ItemAddedEventHandler ItemAdded
Event Type
Type | Description |
---|---|
StatefulCollection.ItemAddedEventHandler<> |
ItemRemoved
On item removed event
Declaration
public event StatefulCollection<T>.ItemRemovedEventHandler ItemRemoved
Event Type
Type | Description |
---|---|
StatefulCollection.ItemRemovedEventHandler<> |
RemoveItem
On remove item event
Declaration
public event StatefulCollection<T>.RemoveItemEventHandler RemoveItem
Event Type
Type | Description |
---|---|
StatefulCollection.RemoveItemEventHandler<> |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Get the enumerator to iterate over the current collection content without removed items
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | Enumerator |