/// <summary> /// Update interface when label changes /// </summary> /// <param name="file"></param> /// <param name="op"></param> void _TagCache_CacheUpdated(CacheUpdatedArgs e) { // 删除结点 TreeNode root = tvClassView.Nodes[e.ProjectIndex]; /* * ClassViewIndex index = root.Tag as ClassViewIndex; * if (index.FileName2TreeNode_Index.ContainsKey(e.File)) * { * List<TreeNode> nodeList = index.FileName2TreeNode_Index[e.File]; * nodeList.Reverse(); * foreach (TreeNode node in nodeList) * { * ITag tag = node.Tag as ITag; * index.TagFullName2TreeNode_Index.Remove(tag.FullName); * } * index.FileName2TreeNode_Index.Remove(e.File); * foreach (TreeNode node in nodeList) * { * if (node.Nodes.Count == 0) // 没有子结点的情况下才删除。像命名空间往往有很多子结点 * node.Remove(); // throw new exception? * } * }*/ // 如果是Update操作,添加结点 if (e.Operator == Operator.Update) { _InsertTags(root, TagCache.GetTags(e.File)); } }
public void Cache_updated_information_is_correct() { Given_a_toggle(ApplicationName, "existingNoChange", "true"); Given_a_toggle(ApplicationName, "existingChange", "true"); Given_a_toggle(ApplicationName, "existingRemoved", "true"); var hobknobClient = Create_hobknob_client(Create_exception_throwing_error_handler()); Given_a_toggle(ApplicationName, "newToggle", "true"); Given_a_toggle(ApplicationName, "existingChange", "false"); Given_a_toggle_is_removed(ApplicationName, "existingRemoved"); CacheUpdatedArgs cacheUpdatedArgs = null; hobknobClient.CacheUpdated += (sender, args) => { if (cacheUpdatedArgs == null) { cacheUpdatedArgs = args; } }; // wait for client to update Thread.Sleep(TimeSpan.FromSeconds(1.2)); Assert.That(cacheUpdatedArgs, Is.Not.Null); var cacheUpdates = cacheUpdatedArgs.Updates.ToDictionary(x => x.Key); Assert.That(cacheUpdates.Count, Is.EqualTo(3)); AssertToggleUpdate(cacheUpdates, "existingChange", true, false); AssertToggleUpdate(cacheUpdates, "existingRemoved", true, null); AssertToggleUpdate(cacheUpdates, "newToggle", null, true); }
void TagCache_CacheUpdated(CacheUpdatedArgs e) { while (!this.IsHandleCreated) { Thread.Sleep(1); } this.Invoke(_updateClassView, new object[] { e }); }