ClassCommonExtensions
A collection of generic extensions used across the codebase.
Definition
Namespace:Telerik.Windows.Diagrams.Core
Assembly:Telerik.Windows.Diagrams.Core.dll
Syntax:
public static class CommonExtensions
Inheritance: objectCommonExtensions
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
collection
ICollection<T>
A collection to be augmented with the given items.
newItems
IEnumerable<T>
The new items to add.
Exceptions
Will be raised if either the collection or the newItems is null.
ClearIfSet(DependencyObject, DependencyProperty)
Clears the property if a value has been set.
Declaration
public static bool ClearIfSet(this DependencyObject dependencyObject, DependencyProperty dependencyProperty)
Parameters
dependencyObject
DependencyObject
The dependency object.
dependencyProperty
DependencyProperty
The dependency property to clear.
Returns
Returns true if the value has been cleared.
Exceptions
Will be raised if either the dependencyObject or the dependencyProperty is null.
Clone(IEnumerable<double>)
Clones the list of doubles and returns a DoubleCollection.
Declaration
public static DoubleCollection Clone(this IEnumerable<double> doubles)
Parameters
doubles
The list to clone.
Returns
DoubleCollection
The cloned list.
Clone<T>(IEnumerable<T>)
Clones the list.
Declaration
public static IList<T> Clone<T>(this IEnumerable<T> list)
Parameters
list
IEnumerable<T>
The list to clone.
Returns
IList<T>
The cloned list.
Exceptions
Will be raised if the underlying list is null.
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
collection
IEnumerable<T>
A collection to be tested for the given items.
otherCollection
IEnumerable<T>
The other collection.
Returns
True if the specified collection contains any of the otherCollection items; otherwise, false.
Exceptions
Will be raised if either the collection or the otherCollection is null.
EnsureListCount<T>(IList<T>, int, 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
list
IList<T>
The list to check.
count
The expected count.
factory
Func<T>
The factory function if more items need to be created.
Returns
Returns true if items had to be removed in order to have the expect count.
Exceptions
Will be raised if the underlying list is null.
EnsureListCountAtLeast<T>(IList<T>, int, 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
list
IList<T>
The list to check.
count
The expected count.
factory
Func<T>
The factory function if more items need to be created.
Returns
Returns true if additional items had to be added.
Exceptions
Will be raised if the underlying list is null.
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
collection
IEnumerable<T>
The collection to iterate.
action
Action<T>
The action to execute on each item.
Exceptions
Will be raised if either the collection or the action is null.
GetActualBounds(IDiagramItem, bool)
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
item
An IDiagramItem item.
isShapeActualBounds
Indicates whether to get the actual (rotated) shape bounds or the normal bounds.
Returns
Rect
GetEnclosingBounds(IEnumerable<IDiagramItem>, bool, bool)
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
items
The diagram items.
isGraphVirtualized
If set to true [is graph virtualized].
isShapeActualBounds
Indicates whether to get the actual (rotated) shape bounds or the normal bounds.
Returns
Rect
RemoveLast<T>(IList<T>)
Removes the last item in the list.
Declaration
public static void RemoveLast<T>(this IList<T> list)
Parameters
list
IList<T>
The list.
Exceptions
Will be raised if the underlying list is null.
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
dependencyObject
DependencyObject
The dependency object.
dependencyProperty
DependencyProperty
The dependency property.
value
The value to set if currently different.
Returns
Return true if the value was set.
Exceptions
Will be raised if either the dependencyObject or the dependencyProperty is null. The value can however be set to null.