CollectionExtensionMethods
Provides extension methods for enumerable collections.
Methods
Add a (possibly) hierarchical layer.
Parameters:
| layers (File3dmLayerTable) | Layer set to search and modify. |
| name (string) | Full path or name of layer. |
Returns: Index of layer or -1.
Add a (possibly) hierarchical layer.
Parameters:
| layers (LayerTable) | Layer set to search and modify. |
| name (string) | Full path or name of layer. |
Returns: Index of layer or -1.
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.
Parameters:
| collection (IEnumerable<T>) | Collection to traverse. |
| comparison (Func<T, T, bool>) | Comparer. |
| commonValue (out T) | Common value, if found. |
Returns: Value shared amongst all entries or null.
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.
Parameters:
| collection (IEnumerable<T>) | Collection to traverse. |
| commonValue (out T) | Common value, if found. |
Returns: True if there was a common value.
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.
Parameters:
| collection (IEnumerable<TType>) | Collection to iterate over. |
| accessor (Func<TType, TValue>) | Method for getting at values in collection items. |
Returns: The value all elements have in common, or null.
Search for a layer first by full path and then by name.
Parameters:
| layers (File3dmLayerTable) | Layer set to search. |
| name (string) | Full path or name of layer. |
Returns: Index of layer or -1.
Search for a layer first by full path and then by name.
Parameters:
| layers (LayerTable) | Layer set to search. |
| name (string) | Full path or name of layer. |
Returns: Index of layer or -1.
Remove an element from a hashset if it exists, or add it if it doesn't.
Parameters:
| hashset (HashSet<T>) | |
| element (T) |
Collect the instance IDs of all objects and subobjects in a collection into a hash set.
Parameters:
| objects (IEnumerable<IDocumentObject>) |
Test whether a predicate holds for any of the values in a collection.
Parameters:
| collection (IEnumerable<T>) | |
| predicate (Func<T, bool>) |