Class
CommonExtensions

A collection of generic extensions used across the codebase.

Definition

Namespace:Telerik.Windows.Diagrams.Core

Assembly:Telerik.Windows.Diagrams.Core.dll

Syntax:

cs-api-definition
public static class CommonExtensions

Inheritance: objectCommonExtensions

Methods

AddRange<T>(ICollection<T>, IEnumerable<T>)

Adds the given range of items to the current collection.

Declaration

cs-api-definition
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

ArgumentNullException

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

cs-api-definition
public static bool ClearIfSet(this DependencyObject dependencyObject, DependencyProperty dependencyProperty)

Parameters

dependencyObject

DependencyObject

The dependency object.

dependencyProperty

DependencyProperty

The dependency property to clear.

Returns

bool

Returns true if the value has been cleared.

Exceptions

ArgumentNullException

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

cs-api-definition
public static DoubleCollection Clone(this IEnumerable<double> doubles)

Parameters

doubles

IEnumerable<double>

The list to clone.

Returns

DoubleCollection

The cloned list.

Clone<T>(IEnumerable<T>)

Clones the list.

Declaration

cs-api-definition
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

ArgumentNullException

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

cs-api-definition
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

bool

True if the specified collection contains any of the otherCollection items; otherwise, false.

Exceptions

ArgumentNullException

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

cs-api-definition
public static bool EnsureListCount<T>(this IList<T> list, int count, Func<T> factory)

Parameters

list

IList<T>

The list to check.

count

int

The expected count.

factory

Func<T>

The factory function if more items need to be created.

Returns

bool

Returns true if items had to be removed in order to have the expect count.

Exceptions

ArgumentNullException

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

cs-api-definition
public static bool EnsureListCountAtLeast<T>(this IList<T> list, int count, Func<T> factory)

Parameters

list

IList<T>

The list to check.

count

int

The expected count.

factory

Func<T>

The factory function if more items need to be created.

Returns

bool

Returns true if additional items had to be added.

Exceptions

ArgumentNullException

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

cs-api-definition
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

ArgumentNullException

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

cs-api-definition
public static Rect GetActualBounds(this IDiagramItem item, bool isShapeActualBounds = true)

Parameters

item

IDiagramItem

An IDiagramItem item.

isShapeActualBounds

bool

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

cs-api-definition
public static Rect GetEnclosingBounds(this IEnumerable<IDiagramItem> items, bool isGraphVirtualized = false, bool isShapeActualBounds = true)

Parameters

items

IEnumerable<IDiagramItem>

The diagram items.

isGraphVirtualized

bool

If set to true [is graph virtualized].

isShapeActualBounds

bool

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

cs-api-definition
public static void RemoveLast<T>(this IList<T> list)

Parameters

list

IList<T>

The list.

Exceptions

ArgumentNullException

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

cs-api-definition
public static bool SetIfDifferent(this DependencyObject dependencyObject, DependencyProperty dependencyProperty, object value)

Parameters

dependencyObject

DependencyObject

The dependency object.

dependencyProperty

DependencyProperty

The dependency property.

value

object

The value to set if currently different.

Returns

bool

Return true if the value was set.

Exceptions

ArgumentNullException

Will be raised if either the dependencyObject or the dependencyProperty is null. The value can however be set to null.