Inheritance: NodeSource, INode
        /// <summary>
        /// Initializes an shared child based on what is in the address space.
        /// </summary>
        protected BaseInstanceSource InitializeSharedChild(
            BaseInstanceSource        sharedChild,
            ConstructInstanceDelegate constructInstanceDelegate,
            NodeId                    referenceTypeId,
            QualifiedName             browseName,
            uint                      numericId,
            object                    configuration)
        {
            CheckNodeManagerState();

            // check if node exists.
            ILocalNode existingChild = NodeManager.GetTargetNode(
                this.NodeId, 
                referenceTypeId, 
                false, 
                true, 
                browseName) as ILocalNode;

            if (existingChild == null)
            {
                if (sharedChild != null && sharedChild.Parent != this)
                {
                    ReferenceSharedChild(sharedChild);
                }

                return null;
            }

            // check if existing child is owned by the object.
            ExpandedNodeId parentId = existingChild.References.FindTarget(ReferenceTypeIds.HasModelParent, false, false, null, 0);

            if (parentId != this.NodeId)
            {
                return sharedChild;
            }
                                
            // construct the child.
            BaseInstanceSource child = constructInstanceDelegate(
                Server, 
                this, 
                referenceTypeId, 
                null, 
                browseName,
                numericId);
            
            // create it.
            child.Create(this.NodeId, child.ReferenceTypeId, null, null, numericId, configuration);

            return child;
        }
        /// <summary>
        /// Replaces a shared child in the address space.
        /// </summary>
        protected virtual BaseInstanceSource DeleteReplacedChild(BaseInstanceSource child)
        {  
            CheckNodeManagerState();

            // save reference and browse name info.
            NodeId referenceTypeId = child.ReferenceTypeId;
            QualifiedName browseName = child.BrowseName;

            // delete from the address space.
            child.Delete();

            // dispose it.
            child.Dispose();

            // add reference to shared child.
            NodeManager.ReferenceSharedNode(this, referenceTypeId, false, browseName);

            // remove reference.
            return null;
        }
        /// <summary>
        /// Removes references to a shared child.
        /// </summary>
        protected virtual BaseInstanceSource UnreferenceSharedChild(BaseInstanceSource child)
        {  
            CheckNodeManagerState();

            if (child != null)
            {
                NodeManager.UnreferenceSharedNode(this, child.ReferenceTypeId, false, child.BrowseName);
            }

            return null;
        }        
        /// <summary>
        /// Replaces a shared child in the address space.
        /// </summary>
        protected virtual BaseInstanceSource ReplaceSharedChild(
            BaseInstanceSource child, 
            NodeId             nodeId,
            NodeId             referenceTypeId,
            QualifiedName      browseName,
            uint               numericId,
            NodeId             typeDefinitionId,
            object             configuration)
        {  
            CheckNodeManagerState();

            // remove links to shared node.
            NodeManager.UnreferenceSharedNode(this, referenceTypeId, false, browseName);

            // initialize replacement.
            child.Initialize(nodeId, referenceTypeId, browseName, numericId, typeDefinitionId);

            // add replacement to the address space.
            child.Create(this.NodeId, child.ReferenceTypeId, null, null, child.NumericId, configuration);
            
            // return replacement.
            return child;
        }        
        /// <summary>
        /// Creates the children for the node.
        /// </summary>
        protected virtual BaseInstanceSource DeleteChild(BaseInstanceSource child)
        {  
            // delete from the address space.
            child.Delete();

            // dispose it.
            child.Dispose();

            // remove reference.
            return null;
        }