Class ServerListExtensions
Inheritance
System.Object
ServerListExtensions
Assembly: Eco.Core.dll
Syntax
public static class ServerListExtensions : Object
Methods
AddUnique<T>(IList<T>, T)
Declaration
public static bool AddUnique<T>(this IList<T> l, T element)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IList<T> |
l |
|
T |
element |
|
Returns
Type |
Description |
System.Boolean |
|
Type Parameters
AddUniqueNonNull<T>(IList<T>, T)
Declaration
public static bool AddUniqueNonNull<T>(this IList<T> l, T element)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IList<T> |
l |
|
T |
element |
|
Returns
Type |
Description |
System.Boolean |
|
Type Parameters
Describe<TKey, TValue>(IDictionary<TKey, TValue>)
Declaration
public static string Describe<TKey, TValue>(this IDictionary<TKey, TValue> dict)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IDictionary<TKey, TValue> |
dict |
|
Returns
Type |
Description |
System.String |
|
Type Parameters
Name |
Description |
TKey |
|
TValue |
|
ElementAtOrDefault<T>(IList<T>, Int32)
Declaration
public static T ElementAtOrDefault<T>(this IList<T> list, int index)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IList<T> |
list |
|
System.Int32 |
index |
|
Returns
Type Parameters
EnsureSize<T>(List<T>, Int32, Func<T>)
Declaration
public static List<T> EnsureSize<T>(this List<T> list, int size, Func<T> makeVal = null)
Parameters
Type |
Name |
Description |
System.Collections.Generic.List<T> |
list |
|
System.Int32 |
size |
|
System.Func<T> |
makeVal |
|
Returns
Type |
Description |
System.Collections.Generic.List<T> |
|
Type Parameters
FirstOrNull<T>(IEnumerable<T>, Func<T, Boolean>)
Declaration
public static Nullable<T> FirstOrNull<T>(this IEnumerable<T> sequence, Func<T, bool> func)
where T : struct, ValueType
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
sequence |
|
System.Func<T, System.Boolean> |
func |
|
Returns
Type |
Description |
System.Nullable<T> |
|
Type Parameters
GetOrDefault<T>(T[], Int32)
Declaration
public static T GetOrDefault<T>(this T[] array, int index)
Parameters
Type |
Name |
Description |
T[] |
array |
|
System.Int32 |
index |
|
Returns
Type Parameters
LastOrNull<T>(IEnumerable<T>)
Declaration
public static Nullable<T> LastOrNull<T>(this IEnumerable<T> sequence)
where T : struct, ValueType
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
sequence |
|
Returns
Type |
Description |
System.Nullable<T> |
|
Type Parameters
LastOrNull<T>(IEnumerable<T>, Func<T, Boolean>)
Declaration
public static Nullable<T> LastOrNull<T>(this IEnumerable<T> sequence, Func<T, bool> func)
where T : struct, ValueType
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
sequence |
|
System.Func<T, System.Boolean> |
func |
|
Returns
Type |
Description |
System.Nullable<T> |
|
Type Parameters
MaxTuple<T>(IEnumerable<T>, Func<T, Single>)
Declaration
public static Tuple<T, float> MaxTuple<T>(this IEnumerable<T> enumeration, Func<T, float> distanceFunc)
where T : class
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
enumeration |
|
System.Func<T, System.Single> |
distanceFunc |
|
Returns
Type |
Description |
System.Tuple<T, System.Single> |
|
Type Parameters
Pairs<T>(IEnumerable<T>)
Declaration
public static IEnumerable<(T, T)> Pairs<T>(this IEnumerable<T> list)
where T : IComparable
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
list |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.ValueTuple<T, T>> |
|
Type Parameters
PairsEachOrder<T>(IEnumerable<T>)
Declaration
public static IEnumerable<(T, T)> PairsEachOrder<T>(this IEnumerable<T> list)
where T : IComparable
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
list |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.ValueTuple<T, T>> |
|
Type Parameters
PairsEachOrderNoSame<T>(IEnumerable<T>)
Declaration
public static IEnumerable<(T, T)> PairsEachOrderNoSame<T>(this IEnumerable<T> list)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
list |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.ValueTuple<T, T>> |
|
Type Parameters
PairsNoSame<T>(IEnumerable<T>, IEnumerable<T>)
Return pairs between list1 and list2, omitting ones where the values are equal.
Declaration
public static IEnumerable<(T, T)> PairsNoSame<T>(this IEnumerable<T> list, IEnumerable<T> listother)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
list |
|
System.Collections.Generic.IEnumerable<T> |
listother |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.ValueTuple<T, T>> |
|
Type Parameters
RemoveAll<T>(IList<T>, Func<T, Boolean>)
Declaration
public static IEnumerable<T> RemoveAll<T>(this IList<T> list, Func<T, bool> p)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IList<T> |
list |
|
System.Func<T, System.Boolean> |
p |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<T> |
|
Type Parameters
RemoveAndLogErrors<T>(IList<T>, String, Func<T, Boolean>)
This function is used to ensure correct state of lists. By default it will remove all null elements. It's usefull to not crash the game if there were some errors on saving/migrations. Anyway these errors needs to be investigated.
Declaration
public static void RemoveAndLogErrors<T>(this IList<T> entries, string name, Func<T, bool> testFunction = null)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IList<T> |
entries |
|
System.String |
name |
|
System.Func<T, System.Boolean> |
testFunction |
|
Type Parameters
ReplaceWith<T>(IList<T>, Predicate<T>, T)
We replace all the items that match the specified condition with the specified item.
IMPORTANT: this doesn't preserve the order of the items inside the list.
Declaration
public static void ReplaceWith<T>(this IList<T> list, Predicate<T> match, T newItem)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IList<T> |
list |
|
System.Predicate<T> |
match |
|
T |
newItem |
|
Type Parameters
SequenceEqual(IEnumerable, IEnumerable)
Declaration
public static bool SequenceEqual(IEnumerable left, IEnumerable right)
Parameters
Type |
Name |
Description |
System.Collections.IEnumerable |
left |
|
System.Collections.IEnumerable |
right |
|
Returns
Type |
Description |
System.Boolean |
|
ToJSON(List<String>, Boolean)
Declaration
public static string ToJSON(this List<string> list, bool quoted)
Parameters
Type |
Name |
Description |
System.Collections.Generic.List<System.String> |
list |
|
System.Boolean |
quoted |
|
Returns
Type |
Description |
System.String |
|