Skip to main content
A newer version of this page is available. .

Clone Object Module

  • 4 minutes to read

The Clone Object module allows end-users to quickly create similar objects by cloning them, and changing the required properties. For this purpose, this module provides a View Controller that contains the CloneObject Action. When executing this Action, the required object is cloned. This topic details this Action’s default behavior and provides information on available customizations.

Important

Currently, we do not to provide built-in support for Entity Framework (EF) in this module, because its implementation heavily depends on our XPO ORM, and we do not have a sufficient number of customer requests in this regard. If you use EF for data access in your XAF application and require a similar functionality for your project, feel free to contact us and describe your business requirements so we can provide you with alternative solutions. In general, you can integrate any custom or standard solution for Entity Framework, which you would implement to solve the same requirement in non-XAF applications. We will also continue monitoring user demand in this regard and it is possible that we will review our current decision in the future.

Clone Object Module Overview

The Clone Object module consists of a single assembly: DevExpress.ExpressApp.CloneObject.v18.2.dll. So, you can add the CloneObjectModule to the common application module to use its CloneObject Action in WinForms and ASP.NET applications. For this purpose, invoke the Module Designer and drag the CloneObject module from the Toolbox to the RequiredModules panel. If you need to add this module to an application project, invoke the Application Designer and drag the CloneObject module from the Toolbox‘s XAF Modules page to the Modules panel on the Designer. Rebuild your solution after adding the module.

Tip

The Clone Object module supplies the CloneObjectViewController View Controller. This Controller contains the CloneObject Single Choice Action, targeted for cloning the currently selected object. In addition, the CloneObject module extends the Application Model‘s BOModel | <Class> nodes with the IModelClassCloneable.IsCloneable property. Set it to true, to enable cloning of class objects.

The CloneObject Action is activated for Views representing an object type whose BOModel | <Class> node’s IsCloneable property is set to true. This Action enables you to create a clone of the current object as an object of the current type. In addition, you can create an object of a class inherited from the current object’s base class. For this purpose, set the base class’ IsCloneable property to true. By default, the CloneObject Action is disabled when there are unsaved changes in the current object, because the clone process works in a separate Object Space. The following image demonstrates the CloneObject Action activated for the Contact class. The Action’s dropdown list contains the Contact type, because the IsCloneable property is set to true for the Person class - the base class for the Contact.

CloneObject

To specify that a particular field or property cannot be cloned, apply the NonCloneableAttribute to it.

Note

The CloneObject Action’s Items collection does not include object types that are prohibited for the current user by the Security System.

Clone Object Module Customization

To edit the settings of the CloneObjectViewController or the CloneObject Action, use the Application Model’s ActionDesign | Actions | CloneObject or ActionDesign | Controllers | DevExpress.ExpressApp.CloneObject.CloneObjectViewController nodes. These nodes are available in the Model Editor when the CloneObject module is added.

To change the behavior of the CloneObjectViewController or CloneObjectAction, create a custom View Controller, and access the Controller and its Action in the Controller.Activated event handler. Refer to the CloneObjectViewController.CloneObjectAction topic, to see an example. Additionally, you can handle events exposed by the CloneObjectViewController class.

See Also