Table of Contents

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

T

The 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

isCycling bool

Whether 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

string

Properties

ActualIndex

Gets the current index position in the collection

public int ActualIndex { get; }

Property Value

int

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

bool

IsGoingBack

Gets or sets whether the collection is currently navigating backwards

public bool IsGoingBack { get; set; }

Property Value

bool

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

bool

Methods

Add(T)

Adds a value to the collection

public void Add(T value)

Parameters

value T

The value to add

AddRange(IList<T>)

Adds multiple values to the collection

public void AddRange(IList<T> list)

Parameters

list IList<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

count int

The 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

count int

The 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

text string

The format string

parameters string[]

The format parameters

ReplaceOnce(T, T)

Replaces the first occurrence of an old value with a new value

public void ReplaceOnce(T oldValue, T newValue)

Parameters

oldValue T

The value to replace

newValue T

The new value

SetIteration(int)

Sets the current iteration index to the specified value

public T SetIteration(int newIndex)

Parameters

newIndex int

The 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

newIndex int

The 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

Action

NewStatus

Event raised when a new status message is generated

public event Action<string>? NewStatus

Event Type

Action<string>