/// <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) { return(predefinedNode); } NodeId typeId = passiveNode.TypeDefinitionId; if (!IsNodeIdInNamespace(typeId) || typeId.IdType != IdType.Numeric) { return(predefinedNode); } switch ((uint)typeId.Identifier) { // Write cases in same way for all defined ObjectTypes case ObjectTypes.ChatLogsType: { if (passiveNode is ChatLogsState) { break; } ChatLogsState activeNode = new ChatLogsState(passiveNode.Parent); activeNode.Create(context, passiveNode); if (passiveNode.Parent != null) { passiveNode.Parent.ReplaceChild(context, activeNode); } return(activeNode); } case ObjectTypes.ChatLogEventType: { if (passiveNode is ChatLogEventState) { break; } ChatLogEventState activeNode = new ChatLogEventState(passiveNode.Parent); activeNode.Create(context, passiveNode); if (passiveNode.Parent != null) { passiveNode.Parent.ReplaceChild(context, activeNode); } return(activeNode); } } return(predefinedNode); }
private void SetupNodes() { m_chatLogsState = FindPredefinedNode <ChatLogsState>(Objects.ChatLogs); m_chatLogsState.Post.OnCall = ChatLogsState_Post; m_chatService.Posted += ChatService_Posted; m_chatService.PostCountChanged += ChatService_PostCountChanged; }