GoDigram for .NET Framework and .NET Core
Northwoods.Go Namespace / GoObject Class / Copy Method
In This Topic
    Copy Method (GoObject)
    In This Topic
    This convenience method just makes a copy of the object itself, using a generic GoCopyDictionary.
    Syntax
    public GoObject Copy()
    Remarks

    The easiest way to add a copy of an object to a document is to call GoDocument.GoDocument.AddCopy.

    This method is implemented as:

    
                  GoDocument doc = this.Document;
                  GoCopyDictionary env;
                  if (doc != null)
                    env = doc.CreateCopyDictionary();
                  else
                    env = new GoCopyDictionary();
                  return env.CopyComplete(this);
                
    GoCopyDictionary.Copy calls CopyObject to allow the object to decide how to copy itself. Although the use of a copy dictionary isn't really needed for the simplest objects, more complex objects (such as GoGroups) may contain references that need to be resolved with a second pass.

    If you want to copy many objects, it will be more efficient to allocate your own GoCopyDictionary, call GoCopyDictionary.Copy on each object, and then finally call GoCopyDictionary.FinishDelayedCopies. But if you are just going to be adding those copied objects into a GoDocument, just call CopyFromCollection(IGoCollection) or the more general override of that method.

    If you want to make many copies of one object, it will be more efficient to allocate your own GoCopyDictionary, and then for each copy you want to make, call GoCopyDictionary.CopyComplete on the object followed by a call to Clear() the dictionary. Clearing the copy dictionary will make sure each CopyComplete call does not share any references with any other copy.

    See Also