This project has moved and is read-only. For the latest updates, please go here.

Cloning shape clones its corresponding ModelObject

Mar 27, 2014 at 3:19 PM
I use NShape to draw some business objects. When I create shapes, I assign them an instance of my BO to the Shape.ModelObject property.

When the shape is resized, the shape clone is created and assigned model object is cloned, too. As the BOs I use are ORM objects, I don't want them to be cloned. So I have created an intermediate model object (deriving from ModelObjectBase) and when my intermediate object is cloned, I assign BO to the cloned model object.

Is this the correct approach?

Thank you,
Mar 27, 2014 at 3:54 PM
The temporary clone of the shape that is used for drawing the resize/movement preview will not be saved to the repository.
It is completely temporary and you should not need to worry about it.
Mar 27, 2014 at 4:48 PM
I'm not using the NShape store mechanisms.

The ORM used for our business objects is DevExpress XPO and cloning shape with XPO object bound to it as ModelObject creates a new XPO object on database level. I would have to do some workarounds to prevent that and the easiest possible way is to create an intermediate object which is used solely as ModelObject (and also derives from ModelObjectBase instead of directly implementing the IModelObject interface).