GoDigram for .NET Framework and .NET Core
Northwoods.Go Namespace / GoObject Class / CopyObject Method
The GoCopyDictionary provides the context to be used for performing the copy.
In This Topic
    CopyObject Method (GoObject)
    In This Topic
    Called during the first phase of the copy process to produce a copy of this object within the given copy dictionary.
    Syntax
    public virtual GoObject CopyObject( 
       GoCopyDictionary env
    )

    Parameters

    env
    The GoCopyDictionary provides the context to be used for performing the copy.

    Return Value

    A newly allocated copy of this object, or null.
    Remarks

    If you just need to make a copy of a GoObject, call GoObject.Copy, or GoDocument.GoDocument.AddCopy, or CopyFromCollection(IGoCollection) if you have more than one object to copy.

    You should override this method in your derived classes when it has some fields that have reference objects that need to be copied. Your override method should first call base.CopyObject(env) to get the newly copied object. The standard implementation of this method for GoObject is to do a shallow copy, by Object.MemberwiseClone(). The result should be the object you return, after performing any other deeper copying of referenced objects that you deem necessary, and after removing references that should not be shared (such as to cached data structures). If base.CopyObject(env) returns null, it's either already copied, or mapped to an existing object in this document, or shouldn't be copied at all.

    The copied object does not belong to any layer or any group, nor does it have any observers; the ultimate caller (i.e. GoDocument.CopyFromCollection(IGoCollection)) is responsible for adding it to the appropriate collection and CopyObjectDelayed is responsible for adding the appropriate observers.

    You probably should not be calling this method for any reason but the initial base.CopyObject(env) call in an override of this method; normally only GoCopyDictionary.Copy is the caller. Within an override of this method, if you need to make a copy of another object, call GoCopyDictionary.Copy instead.

    See Also