Class CommonExtensions
A collection of generic extensions used across the codebase.
Inheritance
Namespace: Telerik.Windows.Diagrams.Core
Assembly: Telerik.Windows.Diagrams.Core.dll
Syntax
public static class CommonExtensions : Object
Methods
AddRange<T>(ICollection<T>, IEnumerable<T>)
Adds the given range of items to the current collection.
Declaration
public static void AddRange<T>(this ICollection<T> collection, IEnumerable<T> newItems)
Parameters
System.Collections.Generic.ICollection<T>
collection
A collection to be augmented with the given items. |
System.Collections.Generic.IEnumerable<T>
newItems
The new items to add. |
Type Parameters
T
|
Exceptions
System.ArgumentNullException
Will be raised if either the |
ClearIfSet(DependencyObject, DependencyProperty)
Clears the property if a value has been set.
Declaration
public static bool ClearIfSet(this DependencyObject dependencyObject, DependencyProperty dependencyProperty)
Parameters
System.Windows.DependencyObject
dependencyObject
The dependency object. |
System.Windows.DependencyProperty
dependencyProperty
The dependency property to clear. |
Returns
System.Boolean
Returns |
Exceptions
System.ArgumentNullException
Will be raised if either the |
Clone(IEnumerable<Double>)
Clones the list of doubles and returns a System.Windows.Media.DoubleCollection.
Declaration
public static DoubleCollection Clone(this IEnumerable<double> doubles)
Parameters
System.Collections.Generic.IEnumerable<System.Double>
doubles
The list to clone. |
Returns
System.Windows.Media.DoubleCollection
The cloned list. |
See Also
Clone<T>(IEnumerable<T>)
Clones the list.
Declaration
public static IList<T> Clone<T>(this IEnumerable<T> list)
Parameters
System.Collections.Generic.IEnumerable<T>
list
The list to clone. |
Returns
System.Collections.Generic.IList<T>
The cloned list. |
Type Parameters
T
The data type of the list. |
Exceptions
System.ArgumentNullException
Will be raised if the underlying |
ContainsAny<T>(IEnumerable<T>, IEnumerable<T>)
Checks for the occurrence of the given items in the collection.
Declaration
public static bool ContainsAny<T>(this IEnumerable<T> collection, IEnumerable<T> otherCollection)
Parameters
System.Collections.Generic.IEnumerable<T>
collection
A collection to be tested for the given items. |
System.Collections.Generic.IEnumerable<T>
otherCollection
The other collection. |
Returns
System.Boolean
|
Type Parameters
T
|
Exceptions
System.ArgumentNullException
Will be raised if either the |
EnsureListCount<T>(IList<T>, Int32, Func<T>)
Ensures the list has exactly the amount of items specified.
Declaration
public static bool EnsureListCount<T>(this IList<T> list, int count, Func<T> factory)
Parameters
System.Collections.Generic.IList<T>
list
The list to check. |
System.Int32
count
The expected count. |
System.Func<T>
factory
The factory function if more items need to be created. |
Returns
System.Boolean
Returns |
Type Parameters
T
The data type of the list. |
Exceptions
System.ArgumentNullException
Will be raised if the underlying |
EnsureListCountAtLeast<T>(IList<T>, Int32, Func<T>)
Ensures that the list contains at least the amount of specified items. If not, the given factory function will be used to add additional items till the expect count is reached.
Declaration
public static bool EnsureListCountAtLeast<T>(this IList<T> list, int count, Func<T> factory)
Parameters
System.Collections.Generic.IList<T>
list
The list to check. |
System.Int32
count
The expected count. |
System.Func<T>
factory
The factory function if more items need to be created. |
Returns
System.Boolean
Returns |
Type Parameters
T
The data type of the list. |
Exceptions
System.ArgumentNullException
Will be raised if the underlying |
ForEach<T>(IEnumerable<T>, Action<T>)
Executes the action for each item in the collection.
Declaration
public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action)
Parameters
System.Collections.Generic.IEnumerable<T>
collection
The collection to iterate. |
System.Action<T>
action
The action to execute on each item. |
Type Parameters
T
|
Exceptions
System.ArgumentNullException
Will be raised if either the |
GetActualBounds(IDiagramItem, Boolean)
Gets the ActualBounds if the given item is an IShape, otherwise the IDiagramItem's Bounds will be returned.
Declaration
public static Rect GetActualBounds(this IDiagramItem item, bool isShapeActualBounds = true)
Parameters
IDiagramItem
item
An IDiagramItem item. |
System.Boolean
isShapeActualBounds
Indicates whether to get the actual (rotated) shape bounds or the normal bounds. |
Returns
System.Windows.Rect
|
GetEnclosingBounds(IEnumerable<IDiagramItem>, Boolean, Boolean)
Gets the enclosing bounds of the list of diagram items.
Declaration
public static Rect GetEnclosingBounds(this IEnumerable<IDiagramItem> items, bool isGraphVirtualized = false, bool isShapeActualBounds = true)
Parameters
System.Collections.Generic.IEnumerable<IDiagramItem>
items
The diagram items. |
System.Boolean
isGraphVirtualized
If set to |
System.Boolean
isShapeActualBounds
Indicates whether to get the actual (rotated) shape bounds or the normal bounds. |
Returns
System.Windows.Rect
|
RemoveLast<T>(IList<T>)
Removes the last item in the list.
Declaration
public static void RemoveLast<T>(this IList<T> list)
Parameters
System.Collections.Generic.IList<T>
list
The list. |
Type Parameters
T
The data type of the list. |
Exceptions
System.ArgumentNullException
Will be raised if the underlying |
SetIfDifferent(DependencyObject, DependencyProperty, Object)
Sets the value of the dependencyProperty
property if it's hasn't that value currently.
Declaration
public static bool SetIfDifferent(this DependencyObject dependencyObject, DependencyProperty dependencyProperty, object value)
Parameters
System.Windows.DependencyObject
dependencyObject
The dependency object. |
System.Windows.DependencyProperty
dependencyProperty
The dependency property. |
System.Object
value
The value to set if currently different. |
Returns
System.Boolean
Return |
Exceptions
System.ArgumentNullException
Will be raised if either the |