Struct InvocationList<TDelegate>
Represents immutable list of delegates.
Inherited Members
Namespace: DotNext.Collections.Specialized
Assembly: DotNext.dll
Syntax
public readonly struct InvocationList<TDelegate> : IReadOnlyList<TDelegate>, IReadOnlyCollection<TDelegate>, IEnumerable<TDelegate>, IEnumerable where TDelegate : MulticastDelegate
Type Parameters
Name | Description |
---|---|
TDelegate | The type of delegates in the list. |
Remarks
This type can be used to store a list of event handlers in situations when the delegate type allows variance. In this case, Combine(params Delegate[]) may not be applicable due to lack of variance support.
Constructors
| Edit this page View SourceInvocationList(TDelegate)
Creates a new list containing a single element.
Declaration
public InvocationList(TDelegate d)
Parameters
Type | Name | Description |
---|---|---|
TDelegate | d | The delegate to add. |
Properties
| Edit this page View SourceCount
Gets the number of delegates in this list.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
Empty
Gets an empty list.
Declaration
public static InvocationList<TDelegate> Empty { get; }
Property Value
Type | Description |
---|---|
InvocationList<TDelegate> |
IsEmpty
Indicates that this list is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
bool |
this[int]
Gets the element at the specified index in the read-only list.
Declaration
public TDelegate this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index of the element to get. |
Property Value
Type | Description |
---|---|
TDelegate | The element at the specified index in the read-only list. |
Span
Gets a span over list of delegates.
Declaration
public ReadOnlySpan<TDelegate> Span { get; }
Property Value
Type | Description |
---|---|
ReadOnlySpan<TDelegate> |
Methods
| Edit this page View SourceAdd(TDelegate?)
Adds a delegate to the list and return a new list.
Declaration
public InvocationList<TDelegate> Add(TDelegate? d)
Parameters
Type | Name | Description |
---|---|---|
TDelegate | d | The delegate to add. |
Returns
Type | Description |
---|---|
InvocationList<TDelegate> | The modified list of delegates. |
Combine()
Combines the delegates in the list to a single delegate.
Declaration
public TDelegate? Combine()
Returns
Type | Description |
---|---|
TDelegate | A list of delegates combined as a single delegate. |
GetEnumerator()
Gets enumerator over all delegates in this list.
Declaration
public InvocationList<TDelegate>.Enumerator GetEnumerator()
Returns
Type | Description |
---|---|
InvocationList<TDelegate>.Enumerator | The enumerator over delegates. |
Remove(TDelegate?)
Removes the delegate from the list.
Declaration
public InvocationList<TDelegate> Remove(TDelegate? d)
Parameters
Type | Name | Description |
---|---|---|
TDelegate | d | The delegate to remove. |
Returns
Type | Description |
---|---|
InvocationList<TDelegate> | The modified list of delegates. |
Operators
| Edit this page View Sourceoperator +(InvocationList<TDelegate>, TDelegate?)
Addes the delegate to the list and returns modified list.
Declaration
public static InvocationList<TDelegate> operator +(InvocationList<TDelegate> list, TDelegate? d)
Parameters
Type | Name | Description |
---|---|---|
InvocationList<TDelegate> | list | The list of delegates. |
TDelegate | d | The delegate to add. |
Returns
Type | Description |
---|---|
InvocationList<TDelegate> | The modified list of delegates. |
operator -(InvocationList<TDelegate>, TDelegate?)
Removes the delegate from the list and returns modified list.
Declaration
public static InvocationList<TDelegate> operator -(InvocationList<TDelegate> list, TDelegate? d)
Parameters
Type | Name | Description |
---|---|---|
InvocationList<TDelegate> | list | The list of delegates. |
TDelegate | d | The delegate to remove. |
Returns
Type | Description |
---|---|
InvocationList<TDelegate> | The modified list of delegates. |