Class ListPatternExtensions
- Namespace
- Garyon.Extensions
- Assembly
- Garyon.dll
Provides extensions for commonly-known types using list patterns.
public static class ListPatternExtensions
- Inheritance
-
ListPatternExtensions
- Inherited Members
Methods
TryGetSingle<TBase, TDerived>(IReadOnlyList<TBase>, out TDerived?)
Tries to get a single element from the given read-only list of a specified type.
public static bool TryGetSingle<TBase, TDerived>(this IReadOnlyList<TBase> list, out TDerived? single) where TDerived : TBase
Parameters
listIReadOnlyList<TBase>The read-only list whose elements to evaluate.
singleTDerivedThe single element of the specified type to get. If the list does not contain a single element, or the single element is not of the specified type, this is default.
Returns
Type Parameters
TBaseThe type of the elements in the list.
TDerivedThe type of the single element that must be matched.
TryGetSingle<TBase, TDerived>(ReadOnlySpan<TBase>, out TDerived?)
Tries to get a single element from the given read-only span of a specified type.
public static bool TryGetSingle<TBase, TDerived>(this ReadOnlySpan<TBase> span, out TDerived? single) where TDerived : TBase
Parameters
spanReadOnlySpan<TBase>The read-only span whose elements to evaluate.
singleTDerivedThe single element of the specified type to get. If the span does not contain a single element, or the single element is not of the specified type, this is default.
Returns
Type Parameters
TBaseThe type of the elements in the span.
TDerivedThe type of the single element that must be matched.
TryGetSingle<TBase, TDerived>(Span<TBase>, out TDerived?)
Tries to get a single element from the given span of a specified type.
public static bool TryGetSingle<TBase, TDerived>(this Span<TBase> span, out TDerived? single) where TDerived : TBase
Parameters
spanSpan<TBase>The span whose elements to evaluate.
singleTDerivedThe single element of the specified type to get. If the span does not contain a single element, or the single element is not of the specified type, this is default.
Returns
Type Parameters
TBaseThe type of the elements in the span.
TDerivedThe type of the single element that must be matched.
TryGetSingle<TBase, TDerived>(TBase[], out TDerived?)
Tries to get a single element from the given array of a specified type.
public static bool TryGetSingle<TBase, TDerived>(this TBase[] array, out TDerived? single) where TDerived : TBase
Parameters
arrayTBase[]The array whose elements to evaluate.
singleTDerivedThe single element of the specified type to get. If the array does not contain a single element, or the single element is not of the specified type, this is default.
Returns
Type Parameters
TBaseThe type of the elements in the array.
TDerivedThe type of the single element that must be matched.