CollectionExtensionMethods

public static class CollectionExtensionMethods
Provides extension methods for enumerable collections.

Methods

AddFlexible

#Example
public static int AddFlexible(this File3dmLayerTable layers, string name)
Add a (possibly) hierarchical layer.
layers (File3dmLayerTable)Layer set to search and modify.
name (string)Full path or name of layer.
Index of layer or -1.

AddFlexible

#Example
public static int AddFlexible(this LayerTable layers, string name)
Add a (possibly) hierarchical layer.
layers (LayerTable)Layer set to search and modify.
name (string)Full path or name of layer.
Index of layer or -1.

CommonValue<T>

#Example
public static bool CommonValue<T>(this IEnumerable<T> collection, Func<T, T, bool> comparison, out T commonValue)
Either return the value that all elements in the collection have or null.
collection (IEnumerable<T>)Collection to traverse.
comparison (Func<T, T, bool>)Comparer.
commonValue (out T)Common value, if found.
Value shared amongst all entries or null.

CommonValue<T>

#Example
public static bool CommonValue<T>(this IEnumerable<T> collection, out T commonValue)
Either return the value that all elements in the collection have or null. This method uses ReferenceEquals to test for equality, you will probably want to use the overload which takes a specific comparison delegate.
collection (IEnumerable<T>)Collection to traverse.
commonValue (out T)Common value, if found.
True if there was a common value.

CommonValue<TValue, TType>

#Example
public static TValue? CommonValue<TValue, TType>(this IEnumerable<TType> collection, Func<TType, TValue> accessor)
Extract a specific struct value all elements in a collection share, or return null. All values are compared using default comparison.
collection (IEnumerable<TType>)Collection to iterate over.
accessor (Func<TType, TValue>)Method for getting at values in collection items.
The value all elements have in common, or null.

FindFlexible

#Example
public static int FindFlexible(this File3dmLayerTable layers, string name)
Search for a layer first by full path and then by name.
layers (File3dmLayerTable)Layer set to search.
name (string)Full path or name of layer.
Index of layer or -1.

FindFlexible

#Example
public static int FindFlexible(this LayerTable layers, string name)
Search for a layer first by full path and then by name.
layers (LayerTable)Layer set to search.
name (string)Full path or name of layer.
Index of layer or -1.

Toggle<T>

#Example
public static void Toggle<T>(this HashSet<T> hashset, T element)
Remove an element from a hashset if it exists, or add it if it doesn't.
hashset (HashSet<T>)
element (T)

ToInstanceIdSet

#Example
public static HashSet<Guid> ToInstanceIdSet(this IEnumerable<IDocumentObject> objects)
Collect the instance IDs of all objects and subobjects in a collection into a hash set.
objects (IEnumerable<IDocumentObject>)

TrueForSome<T>

#Example
public static bool TrueForSome<T>(this IEnumerable<T> collection, Func<T, bool> predicate)
Test whether a predicate holds for any of the values in a collection.
collection (IEnumerable<T>)
predicate (Func<T, bool>)