/// <summary> /// Replaces the generic node with a node specific to the model. /// </summary> protected override NodeState AddBehaviourToPredefinedNode( ISystemContext context, NodeState predefinedNode) { BaseObjectState passiveNode = predefinedNode as BaseObjectState; if (passiveNode != null) { NodeId typeId = passiveNode.TypeDefinitionId; if (IsNodeIdInNamespace(typeId) && typeId.IdType == IdType.Numeric) { switch ((uint)typeId.Identifier) { case ObjectTypes.ServerConfigurationType: { ServerConfigurationState activeNode = new ServerConfigurationState(passiveNode.Parent); activeNode.Create(context, passiveNode); m_serverConfigurationNode = activeNode; // replace the node in the parent. if (passiveNode.Parent != null) { passiveNode.Parent.ReplaceChild(context, activeNode); } return(activeNode); } case ObjectTypes.CertificateGroupFolderType: { CertificateGroupFolderState activeNode = new CertificateGroupFolderState(passiveNode.Parent); activeNode.Create(context, passiveNode); // delete unsupported groups if (m_certificateGroups.All(group => group.BrowseName != activeNode.DefaultHttpsGroup?.BrowseName)) { activeNode.DefaultHttpsGroup = null; } if (m_certificateGroups.All(group => group.BrowseName != activeNode.DefaultUserTokenGroup?.BrowseName)) { activeNode.DefaultUserTokenGroup = null; } if (m_certificateGroups.All(group => group.BrowseName != activeNode.DefaultApplicationGroup?.BrowseName)) { activeNode.DefaultApplicationGroup = null; } // replace the node in the parent. if (passiveNode.Parent != null) { passiveNode.Parent.ReplaceChild(context, activeNode); } return(activeNode); } case ObjectTypes.CertificateGroupType: { var result = m_certificateGroups.FirstOrDefault(group => group.BrowseName == passiveNode.BrowseName); if (result != null) { CertificateGroupState activeNode = new CertificateGroupState(passiveNode.Parent); activeNode.Create(context, passiveNode); result.NodeId = activeNode.NodeId; result.Node = activeNode; // replace the node in the parent. if (passiveNode.Parent != null) { passiveNode.Parent.ReplaceChild(context, activeNode); } return(activeNode); } } break; } } } return(base.AddBehaviourToPredefinedNode(context, predefinedNode)); }
/// <summary> /// Finds the child with the specified browse name. /// </summary> protected override BaseInstanceState FindChild( ISystemContext context, QualifiedName browseName, bool createOrReplace, BaseInstanceState replacement) { if (QualifiedName.IsNull(browseName)) { return null; } BaseInstanceState instance = null; switch (browseName.Name) { case Opc.Ua.Gds.BrowseNames.CertificateGroups: { if (createOrReplace) { if (CertificateGroups == null) { if (replacement == null) { CertificateGroups = new CertificateGroupFolderState(this); } else { CertificateGroups = (CertificateGroupFolderState)replacement; } } } instance = CertificateGroups; break; } case Opc.Ua.Gds.BrowseNames.StartSigningRequest: { if (createOrReplace) { if (StartSigningRequest == null) { if (replacement == null) { StartSigningRequest = new StartSigningRequestMethodState(this); } else { StartSigningRequest = (StartSigningRequestMethodState)replacement; } } } instance = StartSigningRequest; break; } case Opc.Ua.Gds.BrowseNames.StartNewKeyPairRequest: { if (createOrReplace) { if (StartNewKeyPairRequest == null) { if (replacement == null) { StartNewKeyPairRequest = new StartNewKeyPairRequestMethodState(this); } else { StartNewKeyPairRequest = (StartNewKeyPairRequestMethodState)replacement; } } } instance = StartNewKeyPairRequest; break; } case Opc.Ua.Gds.BrowseNames.FinishRequest: { if (createOrReplace) { if (FinishRequest == null) { if (replacement == null) { FinishRequest = new FinishRequestMethodState(this); } else { FinishRequest = (FinishRequestMethodState)replacement; } } } instance = FinishRequest; break; } case Opc.Ua.Gds.BrowseNames.GetCertificateGroups: { if (createOrReplace) { if (GetCertificateGroups == null) { if (replacement == null) { GetCertificateGroups = new GetCertificateGroupsMethodState(this); } else { GetCertificateGroups = (GetCertificateGroupsMethodState)replacement; } } } instance = GetCertificateGroups; break; } case Opc.Ua.Gds.BrowseNames.GetTrustList: { if (createOrReplace) { if (GetTrustList == null) { if (replacement == null) { GetTrustList = new GetTrustListMethodState(this); } else { GetTrustList = (GetTrustListMethodState)replacement; } } } instance = GetTrustList; break; } case Opc.Ua.Gds.BrowseNames.GetCertificateStatus: { if (createOrReplace) { if (GetCertificateStatus == null) { if (replacement == null) { GetCertificateStatus = new GetCertificateStatusMethodState(this); } else { GetCertificateStatus = (GetCertificateStatusMethodState)replacement; } } } instance = GetCertificateStatus; break; } } if (instance != null) { return instance; } return base.FindChild(context, browseName, createOrReplace, replacement); }