Show / Hide Table of Contents

Class ServerListExtensions

Inheritance
System.Object
ServerListExtensions
Namespace: Eco.Core.Utils
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
Name Description
T

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
Name Description
T

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 Description
T
Type Parameters
Name Description
T

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
Name Description
T

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
Name Description
T

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 Description
T
Type Parameters
Name Description
T

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
Name Description
T

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
Name Description
T

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
Name Description
T

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
Name Description
T

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
Name Description
T

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
Name Description
T

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
Name Description
T

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
Name Description
T

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
Name Description
T

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
Name Description
T

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
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾