本文整理匯總了C#中Opc.Ua.BaseInstanceState.Create方法的典型用法代碼示例。如果您正苦於以下問題:C# BaseInstanceState.Create方法的具體用法?C# BaseInstanceState.Create怎麽用?C# BaseInstanceState.Create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Opc.Ua.BaseInstanceState
的用法示例。
在下文中一共展示了BaseInstanceState.Create方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CreateNode
/// <summary>
/// Creates a new instance and assigns unique identifiers to all children.
/// </summary>
/// <param name="context">The operation context.</param>
/// <param name="parentId">An optional parent identifier.</param>
/// <param name="referenceTypeId">The reference type from the parent.</param>
/// <param name="browseName">The browse name.</param>
/// <param name="instance">The instance to create.</param>
/// <returns>The new node id.</returns>
public NodeId CreateNode(
ServerSystemContext context,
NodeId parentId,
NodeId referenceTypeId,
QualifiedName browseName,
BaseInstanceState instance)
{
ServerSystemContext contextToUse = (ServerSystemContext)m_systemContext.Copy(context);
lock (Lock)
{
if (m_predefinedNodes == null)
{
m_predefinedNodes = new NodeIdDictionary<NodeState>();
}
instance.ReferenceTypeId = referenceTypeId;
NodeState parent = null;
if (parentId != null)
{
if (!m_predefinedNodes.TryGetValue(parentId, out parent))
{
throw ServiceResultException.Create(
StatusCodes.BadNodeIdUnknown,
"Cannot find parent with id: {0}",
parentId);
}
parent.AddChild(instance);
}
instance.Create(contextToUse, null, browseName, null, true);
AddPredefinedNode(contextToUse, instance);
return instance.NodeId;
}
}