public virtual void Create(
NodeId parentId,
NodeId referenceTypeId,
NodeId nodeId,
QualifiedName browseName,
uint numericId,
object configuration)
{
CheckNodeManagerState();
lock (DataLock)
{
// update the node id.
if (NodeId.IsNull(nodeId))
{
nodeId = m_nodeId;
}
else
{
m_nodeId = nodeId;
}
// update the browse name.
if (QualifiedName.IsNull(browseName))
{
browseName = m_browseName;
}
else
{
m_browseName = browseName;
if (!QualifiedName.IsNull(browseName))
{
m_displayName = new LocalizedText(browseName.Name);
}
}
// save the numeric id.
if (numericId != 0)
{
m_numericId = numericId;
}
// do any pre-create processing.
configuration = OnBeforeCreate(configuration);
ILocalNode existingNode = null;
// find the node by finding a child of the parent with the same browse path.
if (NodeId.IsNull(this.NodeId))
{
existingNode = NodeManager.GetTargetNode(
parentId,
referenceTypeId,
false,
true,
browseName);
// must assign a node id since one does not already exist.
if (existingNode == null)
{
m_nodeId = NodeManager.CreateUniqueNodeId();
}
else
{
m_nodeId = existingNode.NodeId;
}
}
// find the node with the node id provided.
else
{
existingNode = NodeManager.GetLocalNode(this.NodeId);
}
if (existingNode == null)
{
// create the node.
CreateNode(parentId, referenceTypeId);
// get the default template created by the node manager.
existingNode = NodeManager.GetLocalNode(this.NodeId);
}
// update the attributes.
UpdateAttributes(existingNode);
// update the references.
UpdateReferences(existingNode);
// apply the configuration to the node.
ApplyConfiguration(configuration);
// add the source to the address space.
NodeManager.ReplaceNode(existingNode, this);
// recursively configure the children.
CreateChildren(configuration);
m_created = true;
// do any post-configuration processing.
OnAfterCreate(configuration);
}
}