Class CustomExtensionMethods
- Namespace
- CodeBase
- Assembly
- 4Experience.CodeBase.Core.Runtime.dll
A class that collects a variety of extension methods. Similar to: GenericExtensionMethods
public static class CustomExtensionMethods
- Inheritance
-
CustomExtensionMethods
Properties
NormalizedProbabilitiesCollection
private static List<float> NormalizedProbabilitiesCollection { get; set; }
Property Value
Methods
GetElementByName<T>(List<T>, string)
Get element from list by name where list's items implement IName interface.
public static T GetElementByName<T>(this List<T> collection, string name) where T : IName
Parameters
Returns
- T
Type Parameters
T
GetElementIndexByName<T>(List<T>, string)
Get element index from list by name where list's items implement IName interface.
public static int GetElementIndexByName<T>(this List<T> collection, string name) where T : IName
Parameters
Returns
Type Parameters
T
GetElementNamesCollection<T>(List<T>)
Get array with list's items name where items implement IName interface.
public static string[] GetElementNamesCollection<T>(this List<T> collection) where T : IName
Parameters
collectionList<T>
Returns
- string[]
Type Parameters
T
GetFirstElement<T>(List<T>)
Get list first element (if any problem with collection it will return default of T).
public static T GetFirstElement<T>(this List<T> collection) where T : class
Parameters
collectionList<T>
Returns
- T
Type Parameters
T
GetFirstElement<T>(T[])
Get array first element (if any problem with collection it will return default of T).
public static T GetFirstElement<T>(this T[] collection)
Parameters
collectionT[]
Returns
- T
Type Parameters
T
GetLastElementIndex<T>(List<T>)
Get list last element index (if any problem with collection it will return -1).
public static int GetLastElementIndex<T>(this List<T> collection)
Parameters
collectionList<T>
Returns
Type Parameters
T
GetLastElementIndex<T>(T[])
Get array last element index (if any problem with collection it will return -1).
public static int GetLastElementIndex<T>(this T[] collection)
Parameters
collectionT[]
Returns
Type Parameters
T
GetLastElement<T>(List<T>)
Get list last element (if any problem with collection it will return default of T).
public static T GetLastElement<T>(this List<T> collection)
Parameters
collectionList<T>
Returns
- T
Type Parameters
T
GetLastElement<T>(T[])
Get array last element (if any problem with collection it will return default of T).
public static T GetLastElement<T>(this T[] collection)
Parameters
collectionT[]
Returns
- T
Type Parameters
T
GetRandomElementIndex<T>(List<T>)
Get random index from list (if any problem with collection it will return -1).
Use MathematicalCalculator.UnityRandom.
To set random engine seed refer to MathematicalCalculator.
public static int GetRandomElementIndex<T>(this List<T> collection)
Parameters
collectionList<T>
Returns
Type Parameters
T
GetRandomElementIndex<T>(T[])
Get random index from array (if any problem with collection it will return -1).
Use MathematicalCalculator.UnityRandom.
To set random engine seed refer to MathematicalCalculator.
public static int GetRandomElementIndex<T>(this T[] collection)
Parameters
collectionT[]
Returns
Type Parameters
T
GetRandomElementWithProbability<T>(List<T>)
Pick random element from the list which items implement IProbability interface.
It uses a normalized probability value for each list item. Recalculating this value before the draw itself.
Use MathematicalCalculator.SystemRandom.
To set random engine seed refer to MathematicalCalculator.
public static T GetRandomElementWithProbability<T>(this List<T> collection) where T : IProbability
Parameters
collectionList<T>
Returns
- T
Type Parameters
T
GetRandomElementWithProbabiltity<T>(List<T>)
Pick random element from the list which items implement IProbability interface.
It uses a normalized probability value for each list item. Recalculating this value before the draw itself.
Use MathematicalCalculator.SystemRandom.
To set random engine seed refer to MathematicalCalculator.
[Obsolete("Fixed typo - use GetRandomElementWithProbability method instead - 25.10.2022")]
public static T GetRandomElementWithProbabiltity<T>(this List<T> collection) where T : IProbability
Parameters
collectionList<T>
Returns
- T
Type Parameters
T
GetRandomElement<T>(List<T>)
Get random element from list (if any problem with collection it will return default of T).
Use MathematicalCalculator.UnityRandom.
To set random engine seed refer to MathematicalCalculator.
public static T GetRandomElement<T>(this List<T> collection)
Parameters
collectionList<T>
Returns
- T
Type Parameters
T
GetRandomElement<T>(T[])
Get random element from array (if any problem with collection it will return default of T).
Use MathematicalCalculator.UnityRandom.
To set random engine seed refer to MathematicalCalculator.
public static T GetRandomElement<T>(this T[] collection)
Parameters
collectionT[]
Returns
- T
Type Parameters
T
IsEmpty<T>(List<T>)
Check if target list is empty. First null check.
public static bool IsEmpty<T>(this List<T> collection)
Parameters
collectionList<T>
Returns
Type Parameters
T
IsLastElementIndex<T>(List<T>, int)
Check if provided index is last index in the target list. First null check.
public static bool IsLastElementIndex<T>(this List<T> collection, int index)
Parameters
Returns
Type Parameters
T
RemoveNullElements<T>(List<T>)
Remove all elements from target list which is null.
public static void RemoveNullElements<T>(this List<T> collection)
Parameters
collectionList<T>
Type Parameters
T