ConstrainedList<T> Class
Namespace: Stride.Core.Collections
Assembly: Stride.Core.dll
Represent a collection associated with a constraint. When an item is added to this collection, it is tested against the constraint.
If the test fails, the item can either be discarded, or an exception can be thrown. The desired behavior can be defined with ThrowException.
System.Object →
ConstrainedList<T>
[DataSerializer(typeof(ListAllSerializer<, >), Mode = DataSerializerGenericMode.TypeAndGenericArguments)]
public class ConstrainedList<T> : IList<T>, ICollection<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
|
Improve this Doc
View Source
Constructors
ConstrainedList()
ConstrainedList(Func<ConstrainedList<T>, T, Boolean>, Boolean, String)
public ConstrainedList(Func<ConstrainedList<T>, T, bool> constraint = null, bool throwException = true, string errorMessage = null)
Parameters
| Type |
Name |
Description |
| System.Func<ConstrainedList<T>, T, System.Boolean> |
constraint |
|
| System.Boolean |
throwException |
|
| System.String |
errorMessage |
|
|
Improve this Doc
View Source
Properties
Constraint
Gets or sets the constraint for items added to the collection. If null, this collection behaves like a System.Collections.Generic.List<T>.
public Func<ConstrainedList<T>, T, bool> Constraint { get; set; }
Property Value
Count
public int Count { get; }
Property Value
| Type |
Description |
| System.Int32 |
|
IsReadOnly
public bool IsReadOnly { get; }
Property Value
| Type |
Description |
| System.Boolean |
|
Item[Int32]
public T this[int index] { get; set; }
Parameters
| Type |
Name |
Description |
| System.Int32 |
index |
|
Property Value
ThrowException
Gets or sets whether the collection should throw an System.ArgumentException when an item to add or insert doesn't pass the constraint.
public bool ThrowException { get; set; }
Property Value
| Type |
Description |
| System.Boolean |
|
|
Improve this Doc
View Source
Methods
Add(T)
Parameters
| Type |
Name |
Description |
| T |
item |
|
Clear()
Contains(T)
public bool Contains(T item)
Parameters
| Type |
Name |
Description |
| T |
item |
|
Returns
| Type |
Description |
| System.Boolean |
|
CopyTo(T[], Int32)
public void CopyTo(T[] array, int arrayIndex)
Parameters
| Type |
Name |
Description |
| T[] |
array |
|
| System.Int32 |
arrayIndex |
|
GetEnumerator()
public List<T>.Enumerator GetEnumerator()
Returns
| Type |
Description |
| System.Collections.Generic.List.Enumerator<> |
|
IndexOf(T)
public int IndexOf(T item)
Parameters
| Type |
Name |
Description |
| T |
item |
|
Returns
| Type |
Description |
| System.Int32 |
|
Insert(Int32, T)
public void Insert(int index, T item)
Parameters
| Type |
Name |
Description |
| System.Int32 |
index |
|
| T |
item |
|
Remove(T)
public bool Remove(T item)
Parameters
| Type |
Name |
Description |
| T |
item |
|
Returns
| Type |
Description |
| System.Boolean |
|
RemoveAt(Int32)
public void RemoveAt(int index)
Parameters
| Type |
Name |
Description |
| System.Int32 |
index |
|
|
Improve this Doc
View Source
Explicit Interface Implementations
IEnumerable<T>.GetEnumerator()
IEnumerator<T> IEnumerable<T>.GetEnumerator()
Returns
| Type |
Description |
| System.Collections.Generic.IEnumerator<T> |
|
IEnumerable.GetEnumerator()
IEnumerator IEnumerable.GetEnumerator()
Returns
| Type |
Description |
| System.Collections.IEnumerator |
|
Extension Methods