skip navigation
  • Product Bundles

    DevCraft

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

    • AI Coding Assistants
    • Embedded Reporting
    • Document Processing Libraries
    • SSO Account Sign-in

    Web

    Kendo UI UI for Angular UI for Vue UI for jQuery KendoReact UI for Blazor UI for ASP.NET Core UI for ASP.NET MVC UI for ASP.NET AJAX

    Mobile

    UI for .NET MAUI

    Document Management

    Telerik Document Processing

    Desktop

    UI for .NET MAUI UI for WinUI UI for WinForms UI for WPF

    Reporting

    Telerik Reporting Telerik Report Server

    Testing & Mocking

    Test Studio Telerik JustMock

    CMS

    Sitefinity

    AI Productivity Tools

    AI Coding Assistants

    UI/UX Tools

    ThemeBuilder Design System Kit Templates and Building Blocks

    Debugging

    Fiddler Fiddler Everywhere Fiddler Classic Fiddler Everywhere Reporter FiddlerCore

    Free Tools

    KendoReact Free VB.NET to C# Converter Testing Framework
    View all products
  • Overview
  • Demos
    • What's New
    • Roadmap
    • Release History
  • Support and Learning

    • Support and Learning Hub
    • First Steps
    • Docs
    • Demos
    • Virtual Classroom
    • Forums
    • Videos
    • Blogs
    • Accessibility
    • Submit a Ticket

    Productivity and Design Tools

    • Visual Studio Extensions
    • Visual Studio Templates
    • Embedded Reporting
  • Pricing
  • Shopping cart
    • Account Overview
    • Your Licenses
    • Downloads
    • 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
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 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
System.Windows.DependencyObject dependencyObject

The dependency object.

System.Windows.DependencyProperty 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 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>)

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
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 true [is graph virtualized].

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

Getting Started
  • Install Now
  • Demos
  • SDK Samples Browser
  • Sample Applications
Support Resources
  • Code Library
  • Knowledge Base
  • MVVM Support
  • Videos
  • GitHub SDK Repository
Community
  • Forums
  • Blogs
  • XAML 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.