skip navigation
  • Product Bundles

    DevCraft

    All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:

    • NEW: Design Kits for Figma
    • Online Training
    • Document Processing Library
    • Embedded Reporting for web and desktop
    Web
    Kendo UI UI for jQuery UI for Angular UI for React UI for Vue UI for ASP.NET AJAX UI for ASP.NET MVC UI for ASP.NET Core UI for Blazor UI for Silverlight UI for PHP UI for JSP
    Mobile
    UI for .NET MAUI UI for Xamarin
    Document Management
    Telerik Document Processing
    Desktop
    UI for .NET MAUI UI for WinUI UI for WinForms UI for WPF UI for UWP
    Reporting & Mocking
    Telerik Reporting Telerik Report Server Telerik JustMock
    Automated Testing
    Test Studio Test Studio Dev Edition
    CMS
    Sitefinity
    UI/UX Tools
    ThemeBuilder
    Debugging
    Fiddler Fiddler Everywhere Fiddler Classic Fiddler Jam FiddlerCap FiddlerCore
    Extended Reality
    UI for Unity XR
    Free Tools
    JustAssembly JustDecompile VB.NET to C# Converter Testing Framework
    View all products
  • Overview
  • Demos
    • What's New
    • Roadmap
    • Release History
  • Docs & Support
  • Pricing
  • Search
  • Shopping cart
    • Account Overview
    • Your Licenses
    • Support Center
    • Forum Profile
    • Payment Methods
    • Edit Profile
    • Log out
  • Login
  • Contact Us
  • Try now

Class CommonExtensions

A collection of generic extensions used across the codebase.

Inheritance
System.Object
CommonExtensions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Telerik.Windows.Diagrams.Core
Assembly: Telerik.WinControls.RadDiagram.dll

Syntax

public static class CommonExtensions

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 collection or the newItems is null.

ClearIfSet(RadObject, RadProperty)

Clears the property if a value has been set.

Declaration
public static bool ClearIfSet(this RadObject dependencyObject, RadProperty dependencyProperty)
Parameters
RadObject dependencyObject

The dependency object.

RadProperty dependencyProperty

The dependency property to clear.

Returns
System.Boolean

Returns true if the value has been cleared.

Exceptions
System.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
public static List<double> Clone(this IEnumerable<double> doubles)
Parameters
System.Collections.Generic.IEnumerable<System.Double> doubles

The list to clone.

Returns
System.Collections.Generic.List<System.Double>

The cloned list.

See Also
Clone<T>(IEnumerable<T>)

Clone(DoubleCollection)

Clones the list of doubles and returns a DoubleCollection.

Declaration
public static DoubleCollection Clone(this DoubleCollection doubles)
Parameters
DoubleCollection doubles

The list to clone.

Returns
DoubleCollection

The cloned list.

See Also
Clone<T>(IEnumerable<T>)

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 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
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

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

Type Parameters
T

Exceptions
System.ArgumentNullException

Will be raised if either the collection or the otherCollection is null.

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 true if items had to be removed in order to have the expect count.

Type Parameters
T

The data type of the list.

Exceptions
System.ArgumentNullException

Will be raised if the underlying list is null.

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 true if additional items had to be added.

Type Parameters
T

The data type of the list.

Exceptions
System.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
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 collection or the action is null.

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
Rect

GetActualBoundsWithoutTransform(IDiagramItem)

Gets the ActualBounds if the given item is an IShape, otherwise the IDiagramItem's Bounds will be returned.

Declaration
public static Rect GetActualBoundsWithoutTransform(this IDiagramItem item)
Parameters
IDiagramItem item

An IDiagramItem item.

Returns
Rect

GetActualBoundsWithRotationTransform(IDiagramItem)

Gets the ActualBounds if the given item is an IShape, otherwise the IDiagramItem's Bounds will be returned.

Declaration
public static Rect GetActualBoundsWithRotationTransform(this IDiagramItem item)
Parameters
IDiagramItem item

An IDiagramItem item.

Returns
Rect

GetEnclosingBounds(IEnumerable<IDiagramItem>, Boolean, 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, bool useControlBoundingRectangle = false)
Parameters
System.Collections.Generic.IEnumerable<IDiagramItem> items

The diagram items.

System.Boolean isGraphVirtualized

If set to true [is graph virtualized].

System.Boolean isShapeActualBounds

Indicates whether to get the actual (rotated) shape bounds or the normal bounds.

System.Boolean useControlBoundingRectangle

useControlBoundingRectangle

Returns
Rect

GetEnclosingBoundsRotated(IEnumerable<IDiagramItem>)

Gets the enclosing bounds of the list of diagram items.

Declaration
public static Rect GetEnclosingBoundsRotated(this IEnumerable<IDiagramItem> items)
Parameters
System.Collections.Generic.IEnumerable<IDiagramItem> items

The diagram items.

Returns
Rect

GetEnclosingBoundsWithoutTransform(IEnumerable<IDiagramItem>, Boolean, Boolean, Boolean)

Gets the enclosing bounds of the list of diagram items.

Declaration
public static Rect GetEnclosingBoundsWithoutTransform(this IEnumerable<IDiagramItem> items, bool isGraphVirtualized = false, bool isShapeActualBounds = true, bool useControlBoundingRectangle = false)
Parameters
System.Collections.Generic.IEnumerable<IDiagramItem> items

The diagram items.

System.Boolean isGraphVirtualized

If set to true [is graph virtualized].

System.Boolean isShapeActualBounds

Indicates whether to get the actual (rotated) shape bounds or the normal bounds.

System.Boolean useControlBoundingRectangle

Returns
Rect

enclosingBounds

IsLocalValueSet(RadObject, RadProperty)

Determines whether the specified dependency property local value is set.

Declaration
public static bool IsLocalValueSet(this RadObject dependencyObject, RadProperty property)
Parameters
RadObject dependencyObject

The dependency object.

RadProperty property

The property.

Returns
System.Boolean

See Also
System.Windows.DependencyObject.ReadLocalValue(System.Windows.DependencyProperty)

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 list is null.

SetIfDifferent(RadObject, RadProperty, Object)

Sets the value of the dependencyProperty property if it's hasn't that value currently.

Declaration
public static bool SetIfDifferent(this RadObject dependencyObject, RadProperty dependencyProperty, object value)
Parameters
RadObject dependencyObject

The dependency object.

RadProperty dependencyProperty

The dependency property.

System.Object value

The value to set if currently different.

Returns
System.Boolean

Return true if the value was set.

Exceptions
System.ArgumentNullException

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

Was this article helpful?

Tell us how we can improve this article

Skip
Getting Started
  • Install Now
  • Demos
  • Step-by-Step Tutorial
  • Sample Applications
  • SDK Samples
  • Visual Studio Extensions
Support Resources
  • Code Library
  • Knowledge Base
  • Videos
Community
  • Forums
  • Blogs
  • Feedback Portal
  • Document Processing Feedback Portal

Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.