Table of Contents

Class ListExtensions

Namespace
Playnite
Assembly
Playnite.SDK.dll

Represents class with various extension methods for IEnumerable lists.

public static class ListExtensions
Inheritance
ListExtensions
Inherited Members

Methods

AddIfNotNull<T>(ICollection<T>, T?)

public static bool AddIfNotNull<T>(this ICollection<T> source, T? item)

Parameters

source ICollection<T>
item T

Returns

bool

Type Parameters

T

AddMissingBy<T>(IList<T>, T, Func<T, bool>)

public static bool AddMissingBy<T>(this IList<T> source, T item, Func<T, bool> predicate)

Parameters

source IList<T>
item T
predicate Func<T, bool>

Returns

bool

Type Parameters

T

AddMissing<T>(IList<T>, IEnumerable<T>)

Adds new items to the list only if they are not already part of the list.

public static bool AddMissing<T>(this IList<T> source, IEnumerable<T> items)

Parameters

source IList<T>
items IEnumerable<T>

Returns

bool

True if an item was added, false if no item was added.

Type Parameters

T

AddMissing<T>(IList<T>, T)

Adds new item to the list only if it's not already part of the list.

public static bool AddMissing<T>(this IList<T> source, T item)

Parameters

source IList<T>
item T

Returns

bool

True if item was added, false if it's already part of the list.

Type Parameters

T

AddRangeIfNotNull<T>(ICollection<T>, IEnumerable<T>?)

public static bool AddRangeIfNotNull<T>(this ICollection<T> source, IEnumerable<T>? items)

Parameters

source ICollection<T>
items IEnumerable<T>

Returns

bool

Type Parameters

T

AddRange<T>(HashSet<T>, IEnumerable<T>?)

public static bool AddRange<T>(this HashSet<T> source, IEnumerable<T>? toAdd)

Parameters

source HashSet<T>
toAdd IEnumerable<T>

Returns

bool

Type Parameters

T

ContainsPartOfString(IEnumerable<string>?, string, StringComparison)

Checks if source collection contains part of specified string.

public static bool ContainsPartOfString(this IEnumerable<string>? source, string value, StringComparison comparison = StringComparison.InvariantCultureIgnoreCase)

Parameters

source IEnumerable<string>
value string
comparison StringComparison

Returns

bool

ContainsString(IEnumerable<string>?, string, StringComparison)

Checks if source collection contains specified string completely.

public static bool ContainsString(this IEnumerable<string>? source, string value, StringComparison comparison = StringComparison.InvariantCultureIgnoreCase)

Parameters

source IEnumerable<string>
value string
comparison StringComparison

Returns

bool

ContainsStringPartial(IEnumerable<string>?, string, StringComparison)

Checks if part of specified string is part of the collection.

public static bool ContainsStringPartial(this IEnumerable<string>? source, string value, StringComparison comparison = StringComparison.InvariantCultureIgnoreCase)

Parameters

source IEnumerable<string>
value string
comparison StringComparison

Returns

bool

Contains<T>(IList<T>?, IList<T>?)

Check if collection contains all items from other collection (in any order).

public static bool Contains<T>(this IList<T>? source, IList<T>? target)

Parameters

source IList<T>
target IList<T>

Returns

bool

Type Parameters

T

EmptyIfNull<T>(IEnumerable<T>?)

public static IEnumerable<T> EmptyIfNull<T>(this IEnumerable<T>? source)

Parameters

source IEnumerable<T>

Returns

IEnumerable<T>

Type Parameters

T

FindIndex<T>(IList<T>, Predicate<T>)

public static int FindIndex<T>(this IList<T> source, Predicate<T> match)

Parameters

source IList<T>
match Predicate<T>

Returns

int

Type Parameters

T

ForEachAsync<T>(IEnumerable<T>?, Func<T, Task>)

public static Task ForEachAsync<T>(this IEnumerable<T>? source, Func<T, Task> action)

Parameters

source IEnumerable<T>
action Func<T, Task>

Returns

Task

Type Parameters

T

ForEach<T>(IEnumerable<T>?, Action<T>)

public static void ForEach<T>(this IEnumerable<T>? source, Action<T> action)

Parameters

source IEnumerable<T>
action Action<T>

Type Parameters

T

GetCommonItems<T>(IEnumerable<IEnumerable<T>>)

Gets items contained in all colletions.

public static HashSet<T> GetCommonItems<T>(IEnumerable<IEnumerable<T>> input)

Parameters

input IEnumerable<IEnumerable<T>>

Returns

HashSet<T>

Type Parameters

T

GetDistinctItemsP<T>(params IEnumerable<T>[])

Gets items distinct to all collections.

public static HashSet<T> GetDistinctItemsP<T>(params IEnumerable<T>[] lists) where T : notnull

Parameters

lists IEnumerable<T>[]

Returns

HashSet<T>

Type Parameters

T

GetDistinctItems<T>(IEnumerable<IEnumerable<T>>)

Gets items distinct to all collections.

public static HashSet<T> GetDistinctItems<T>(IEnumerable<IEnumerable<T>> input) where T : notnull

Parameters

input IEnumerable<IEnumerable<T>>

Returns

HashSet<T>

Type Parameters

T

GetItems(ICollection)

public static List<object> GetItems(this ICollection source)

Parameters

source ICollection

Returns

List<object>

HasItems<T>(IEnumerable<T>?)

Check if collection has any items.

public static bool HasItems<T>(this IEnumerable<T>? source)

Parameters

source IEnumerable<T>

Returns

bool

Type Parameters

T

HasItems<T>(IEnumerable<T>?, Func<T, bool>)

Check if collection has any items.

public static bool HasItems<T>(this IEnumerable<T>? source, Func<T, bool> predicate)

Parameters

source IEnumerable<T>
predicate Func<T, bool>

Returns

bool

Type Parameters

T

HasNonEmptyItems(IEnumerable<string>?)

Checks if collection has any non-empty string items.

public static bool HasNonEmptyItems(this IEnumerable<string>? source)

Parameters

source IEnumerable<string>

Returns

bool

IntersectsExactlyWith(IEnumerable<string>?, IEnumerable<string>?, StringComparison)

Checks if source collection contains any items from target one.

public static bool IntersectsExactlyWith(this IEnumerable<string>? source, IEnumerable<string>? target, StringComparison comparison = StringComparison.InvariantCultureIgnoreCase)

Parameters

source IEnumerable<string>
target IEnumerable<string>
comparison StringComparison

Returns

bool

True if target collection contains items that are also part of source collection.

IntersectsPartiallyWith(IEnumerable<string>?, IEnumerable<string>?, StringComparison)

Checks if source collection contains any items from target one, even if just partially.

public static bool IntersectsPartiallyWith(this IEnumerable<string>? source, IEnumerable<string>? target, StringComparison comparison = StringComparison.InvariantCultureIgnoreCase)

Parameters

source IEnumerable<string>
target IEnumerable<string>
comparison StringComparison

Returns

bool

True if target collection contains items that are also part of source collection.

IntersectsWith<T>(HashSet<T>?, HashSet<T>?)

public static bool IntersectsWith<T>(this HashSet<T>? source, HashSet<T>? target)

Parameters

source HashSet<T>
target HashSet<T>

Returns

bool

Type Parameters

T

IsDictionaryEqual<TKey, TValue>(Dictionary<TKey, TValue>?, Dictionary<TKey, TValue>?)

public static bool IsDictionaryEqual<TKey, TValue>(this Dictionary<TKey, TValue>? source, Dictionary<TKey, TValue>? target) where TKey : notnull

Parameters

source Dictionary<TKey, TValue>
target Dictionary<TKey, TValue>

Returns

bool

Type Parameters

TKey
TValue

IsHashSetEqual<T>(HashSet<T>?, HashSet<T>?)

public static bool IsHashSetEqual<T>(this HashSet<T>? source, HashSet<T>? target)

Parameters

source HashSet<T>
target HashSet<T>

Returns

bool

Type Parameters

T

IsListEqualExact<T>(IList<T>?, IList<T>?)

Checks if two collections contain the same items in the same order.

public static bool IsListEqualExact<T>(this IList<T>? source, IList<T>? target)

Parameters

source IList<T>
target IList<T>

Returns

bool

Type Parameters

T

IsListEqual<T>(IList<T>?, IList<T>?)

public static bool IsListEqual<T>(this IList<T>? source, IList<T>? target)

Parameters

source IList<T>
target IList<T>

Returns

bool

Type Parameters

T

IsListEqual<T>(IList<T>?, IList<T>?, IEqualityComparer<T>)

Checks if two collections contain the same items in any order.

public static bool IsListEqual<T>(this IList<T>? source, IList<T>? target, IEqualityComparer<T> comparer)

Parameters

source IList<T>
target IList<T>
comparer IEqualityComparer<T>

Returns

bool

Type Parameters

T

Merge<T>(params HashSet<T>?[])

public static HashSet<T> Merge<T>(params HashSet<T>?[] lists)

Parameters

lists HashSet<T>[]

Returns

HashSet<T>

Type Parameters

T

Merge<T>(IEnumerable<IEnumerable<T>>)

Merge collections together.

public static List<T> Merge<T>(IEnumerable<IEnumerable<T>> lists)

Parameters

lists IEnumerable<IEnumerable<T>>

Returns

List<T>

Type Parameters

T

Merge<T>(IList<T>, IList<T>?)

Merge two collections together.

public static List<T> Merge<T>(IList<T> list1, IList<T>? list2)

Parameters

list1 IList<T>
list2 IList<T>

Returns

List<T>

Type Parameters

T

RemoveIfNotNull<T>(ICollection<T>, T?)

public static bool RemoveIfNotNull<T>(this ICollection<T> source, T? item)

Parameters

source ICollection<T>
item T

Returns

bool

Type Parameters

T

Remove<T>(ICollection<T>, IEnumerable<T>)

public static void Remove<T>(this ICollection<T> source, IEnumerable<T> toRemove)

Parameters

source ICollection<T>
toRemove IEnumerable<T>

Type Parameters

T

ToObservableCollection<T>(IEnumerable<T>)

public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> source)

Parameters

source IEnumerable<T>

Returns

ObservableCollection<T>

Type Parameters

T

TryGetItem<T>(IEnumerable<T>?, Func<T, bool>, out T?)

public static bool TryGetItem<T>(this IEnumerable<T>? source, Func<T, bool> predicate, out T? foundItem) where T : class

Parameters

source IEnumerable<T>
predicate Func<T, bool>
foundItem T

Returns

bool

Type Parameters

T