public COMObject(COMVariant replacedObject) { if (false == replacedObject.IsCOMProxy) { throw new ArgumentException("argument is not a com proxy"); } // remove variant from parent and add himself COMObject parent = replacedObject.ParentObject; parent.RemoveChildObject(replacedObject); parent.AddChildObject(this); // store members _parentObject = parent; _underlyingObject = replacedObject.UnderlyingObject; _instanceType = replacedObject.InstanceType; }
public COMObject(COMObject replacedObject) { // copy proxy _underlyingObject = replacedObject.UnderlyingObject; _parentObject = replacedObject.ParentObject; _instanceType = replacedObject.InstanceType; // copy childs foreach (IObject item in replacedObject.ListChildObjects) { AddChildObject(item); } // remove old object from parent chain if (null != replacedObject.ParentObject) { COMObject parentObject = replacedObject.ParentObject; parentObject.RemoveChildObject(replacedObject); // add himself as child to parent object parentObject.AddChildObject(this); } }