/// <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> /// Initializes an optinal child based on what is in the address space. /// </summary> protected BaseInstanceSource InitializeOptionalChild( ConstructInstanceDelegate constructInstanceDelegate, NodeId referenceTypeId, QualifiedName browseName, uint numericId, object configuration) { CheckNodeManagerState(); // check if nothing to do. if (constructInstanceDelegate == null) { return null; } // check if node exists. ILocalNode existingChild = NodeManager.GetTargetNode( this.NodeId, referenceTypeId, false, true, browseName) as ILocalNode; if (existingChild == null) { return null; } BaseInstanceSource child = constructInstanceDelegate( Server, this, referenceTypeId, null, browseName, numericId); // create it. child.Create(this.NodeId, child.ReferenceTypeId, null, null, numericId, configuration); return child; }