Class CyclingCollection<T>
- Namespace
- SunamoCollectionsGeneric.Collections
- Assembly
- SunamoCollectionsGeneric.dll
Collection that supports cycling through items with forward and backward navigation
public class CyclingCollection<T>
Type Parameters
TThe type of elements in the collection
- Inheritance
-
CyclingCollection<T>
- Derived
- Inherited Members
- Extension Methods
Constructors
CyclingCollection()
Initializes a new instance of the CyclingCollection class
public CyclingCollection()
CyclingCollection(bool)
Initializes a new instance with the specified cycling behavior
public CyclingCollection(bool isCycling)
Parameters
isCyclingboolWhether to cycle back to the beginning when reaching the end
Fields
XUnableToLoadElementAddSomeAndTryAgain
Error message for when unable to load element
public const string XUnableToLoadElementAddSomeAndTryAgain = "UnableToLoadElementAddSomeAndTryAgain"
Field Value
Properties
ActualIndex
Gets the current index position in the collection
public int ActualIndex { get; }
Property Value
GetIteration
If can't be obtained, try to get element previous or next.
public T GetIteration { get; }
Property Value
- T
GetIterationSimple
Gets the current item without error handling
public T GetIterationSimple { get; }
Property Value
- T
IsCycling
Gets or sets whether the collection cycles back to the beginning when reaching the end
public bool IsCycling { get; set; }
Property Value
IsGoingBack
Gets or sets whether the collection is currently navigating backwards
public bool IsGoingBack { get; set; }
Property Value
Items
Gets or sets the list of items in the collection
public List<T> Items { get; set; }
Property Value
- List<T>
MakesSpaces
Gets or sets whether to include spaces in formatted output
public bool MakesSpaces { get; set; }
Property Value
Methods
Add(T)
Adds a value to the collection
public void Add(T value)
Parameters
valueTThe value to add
AddRange(IList<T>)
Adds multiple values to the collection
public void AddRange(IList<T> list)
Parameters
listIList<T>The list of values to add
Before()
Moves to the previous item in the collection
public T Before()
Returns
- T
The previous item
Before(int)
Moves backward by the specified number of items
public T Before(int count)
Parameters
countintThe number of items to move backward
Returns
- T
The item at the new position
Clear()
Removes all items from the collection
public void Clear()
Next()
Moves to the next item in the collection
public T Next()
Returns
- T
The next item
Next(int)
Moves forward by the specified number of items
public T Next(int count)
Parameters
countintThe number of items to move forward
Returns
- T
The item at the new position
OnChange()
Triggers the Change event
public void OnChange()
OnNewStatus(string, params string[])
Triggers the NewStatus event with a formatted message
public void OnNewStatus(string text, params string[] parameters)
Parameters
ReplaceOnce(T, T)
Replaces the first occurrence of an old value with a new value
public void ReplaceOnce(T oldValue, T newValue)
Parameters
oldValueTThe value to replace
newValueTThe new value
SetIteration(int)
Sets the current iteration index to the specified value
public T SetIteration(int newIndex)
Parameters
newIndexintThe new index position
Returns
- T
The item at the new index
SetIterationWithoutEvent(int)
Sets the iteration index without triggering the Change event
public void SetIterationWithoutEvent(int newIndex)
Parameters
newIndexintThe new index position
ToString()
Returns a string representation showing current position and total count
public override string ToString()
Returns
- string
A string in the format "current/total"
Events
Change
Event raised when the collection state changes
public event Action? Change
Event Type
NewStatus
Event raised when a new status message is generated
public event Action<string>? NewStatus