When is IModelObject.Clone() used?

Nov 14, 2012 at 1:10 PM

Hi,

Could You please clarify if IModelObject.Clone() is used for creating preview shape's model only?

Coordinator
Nov 20, 2012 at 8:19 AM

No, it is used for copying model objects. The reason why you cannot find it when searching for references of ModelObject.Clone is, that there is an internal helper class used for cloning that is used in most cases.

Nov 30, 2012 at 9:33 AM

Thank you for your reply.

Which exaclty functionality will suffer if I do not implement this method properly (e.g. will clone only part of properties)?

Coordinator
Nov 30, 2012 at 12:13 PM
Comanche wrote:
Which exaclty functionality will suffer if I do not implement this method properly (e.g. will clone only part of properties)?

Creating from Templates (and therefore from ToolBox) and Cut/Copy & Paste.
Perhaps it does not affect the functionality at all - depends on the properties you are not cloning and their influence on shapes or other model objects.

The framework does not really require the properties to be cloned but the internal state of your model objects may become inconsistent - depends on what you are doing, expecting, etc.
Just try out what happens...

Dec 25, 2012 at 11:37 AM

Is it safe to perform shallow copy in Clone() implementation (for properties of "complex" types)? i.e. just to assign reference to the same instance of the property's value

Feb 3, 2013 at 12:46 PM
Up.
Coordinator
Feb 4, 2013 at 10:37 AM
Sorry - I overlooked this post.

As long as it works in your application, it should be safe:
The framework does more or less nothing with the model objects.
Feb 4, 2013 at 11:03 AM
Very good, thank you!