public void VisitDictionaryElement(DictionaryElement element) { DictionaryElementsCount += 1; IEnumerable<ITreeElement> childrens = element.GetChilds(); foreach (var child in childrens) { child.Visit(this); } }
public void ChildsCount() { Dictionary<string, object> dict = new Dictionary<string, object>(); dict.Add("asd", "fgh"); dict.Add("123", 123); DictionaryElement elem = new DictionaryElement("some_name", dict); Assert.AreEqual(2, elem.GetChilds().Count()); }
public void ChildsElements() { Dictionary<object, object> dict = new Dictionary<object, object>(); dict.Add("ads", 123); dict.Add("fgh", 456); dict.Add("jkl", 789); dict.Add(10, "11"); dict.Add(1, 1); DictionaryElement elem = new DictionaryElement("dict", dict); IEnumerable<ITreeElement> childs = elem.GetChilds(); Assert.AreEqual("ads", childs.ElementAt(0).Name); Assert.AreEqual("1", childs.Last().Name); Assert.AreEqual("jkl", childs.ElementAt(2).Name); }
public void VisitDictionaryElement(DictionaryElement element) { if (_visited.ContainsKey(element.ValueObject)) { return; } _visited.Add(element.ValueObject, true); depth++; IEnumerable<ITreeElement> childrens = element.GetChilds(); for (int i = 0; i < depth; ++i) { _writer.Write(" "); } _writer.WriteLine("Name: {0}", element.Name); foreach (var child in childrens) { child.Visit(this); } depth--; }