/// <summary> /// 节点更新,派发消息 /// </summary> public void MarkChange(DotTreeNode node) { if (node != RootNode) { EventMgr.Instance.Notify(node.Key.GetHashCode(), node.NoticeCount); } }
/// <summary> /// 添加模块 /// </summary> private void AddModule(string moduleName) { var node = new DotTreeNode(moduleName); if (RootNode.AddChild(node)) { _map[moduleName] = node; } }
/// <summary> /// 添加子模块 /// </summary> private void AddSubModule(string mainName, string subName) { var parent = Get(mainName); if (parent == null) { Loger.Error("[dot][main module null]"); return; } var node = new DotTreeNode(subName); if (parent.AddChild(node)) { _map[subName] = node; } }
/// <summary> /// 移除子节点 /// </summary> public bool RemoveChild(DotTreeNode node) { if (!_childNodes.Contains(node)) { Loger.Error("[dot][remove no exist]--->" + node.Key); return(false); } node.Parent = null; _childNodes.Remove(node); if (node._count != 0) { _IncrementUpdate(-node._count); } return(true); }
/// <summary> /// 添加子节点,要求key值唯一,不重复添加 /// </summary> /// <param name="node"></param> public bool AddChild(DotTreeNode node) { foreach (var t in _childNodes) { if (t == node || t.Key.Equals(node.Key)) { Loger.Error("[dot][repeated add]--->" + node.Key); return(false); } } node.Parent = this; _childNodes.Add(node); if (node._count != 0) { _IncrementUpdate(node._count); } return(true); }