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;
}
#endregion