Game.Debug.ExtensionsHelpers
Assembly:
Assembly-CSharp (typical for Cities: Skylines 2 mod/game code; this class is included in the main game assembly)
Namespace: Game.Debug
Type: public static class
Base: System.Object
Summary:
Utility extension methods for ObservableList
Fields
- None.
This is a static helper class and does not define instance fields.
Properties
- None.
No properties are defined by this class.
Constructors
- None (static class).
As a static class, there are no public constructors or instance initializers.
Methods
public static void Add<T>(this ObservableList<T> list, IEnumerable<T> items)
Adds each element from the provided IEnumerableto the ObservableList by calling list.Add(item) for every item. If items is null, this method will simply do nothing (no exception is thrown). Use this to append multiple items in one call instead of iterating externally.
Additional notes:
- Complexity is O(n) in the number of items in the enumerable (plus whatever cost ObservableList
public static int Remove<T>(this ObservableList<T> list, IEnumerable<T> items)
Removes each element in the provided IEnumerablefrom the ObservableList by calling list.Remove(item). The method counts and returns the number of successful removals (i.e., number of times list.Remove(item) returned true). If items is null, the method returns 0.
Additional notes:
- Return value: integer count of removed items.
- Complexity is O(n) in the number of items in the enumerable (plus whatever cost ObservableList
Usage Example
using System.Collections.Generic;
using Game.Debug;
// Example usage of ExtensionsHelpers:
void Example()
{
var list = new ObservableList<string>();
list.Add("existing");
// Add multiple items at once
IEnumerable<string> toAdd = new[] { "apple", "banana", "cherry" };
list.Add(toAdd);
// Remove multiple items at once; returns how many were removed
IEnumerable<string> toRemove = new[] { "banana", "nonexistent" };
int removedCount = list.Remove(toRemove); // removedCount == 1
}
Notes and cautions:
- These are extension methods; ensure the namespace Game.Debug is in scope (via using Game.Debug) to call them as instance-style methods (list.Add(items)).
- Because each element is added/removed individually, any side-effects or notifications raised by ObservableList