public void ReflectChildList() { Setup.TimerStart($"==>{Setup.CallerName()} Started"); var lst = SdcUtil.ReflectChildList(Setup.FD); foreach (var n in lst) { Debug.Print($"{n.order}: \t Name: {n.name}"); } Setup.TimerPrintSeconds(" seconds: ", $"\r\n<=={Setup.CallerName()} Complete"); }
public void MoveListItemInList() { Setup.TimerStart($"==>{Setup.CallerName()} Started"); //FD.TopNode.ReorderNodes(); var li = Setup.FD.Nodes.Where(n => n.Value is ListItemType liTest && liTest.ID == "38493.100004300").FirstOrDefault().Value as ListItemType; Assert.IsTrue(li is ListItemType); List <BaseType> lst1; List <BaseType> lst2; List <BaseType> lst3; lst1 = SdcUtil.ReflectChildList(Setup.FD.GetListItemByID("51689.100004300")); lst2 = SdcUtil.ReflectChildList(Setup.FD.GetListItemByID("38493.100004300")); lst3 = SdcUtil.ReflectChildList(Setup.FD.GetItemByName("lst_44135_3")); lst3 = SdcUtil.ReflectSubtree(Setup.FD.GetSectionByID("43969.100004300")); //foreach (var n in lst3) Debug.Print(n.name); var tc = new TreeComparer(); lst3.Sort(tc); foreach (var n in lst3) { Debug.Print(n.name + ": " + n.ElementName + ", " + n.ObjectID); } var lst4 = Setup.FD.Nodes.Values.ToList(); var res = lst4[0].GetType().GetProperties() .Where(p => p.GetCustomAttributes <XmlElementAttribute>().Count() > 0 && p.GetValue(lst4[0]) != null) .Select(p => p.GetValue(lst4[0])).ToList(); var propList = new List <BaseType>(); while (false) { foreach (object o in res) { var bt = o as BaseType; if (bt != null) { Debug.Print(bt.name); propList.Add(bt); } else if (o is IList il) { foreach (var n in il.OfType <BaseType>()) { Debug.Print(n.name); propList.Add(n); } } } } propList.Sort(new TreeComparer()); int i = 0; foreach (var n in propList) { Debug.Print((i++).ToString() + ": " + n.name); } SdcUtil.ReflectSubtree(lst4[0], true, true); foreach (var n in lst4) { Debug.Print(n.name + ": " + n.ElementName + ", " + n.ObjectID.ToString() + ", order:" + n.order.ToString()); } lst4.Sort(tc); var list = (ListType)li.ParentNode; li.Move(list, 6); Assert.IsTrue(SdcUtil.GetPropertyInfo(li).ItemIndex == 6); li.Move(list, 99); Assert.IsTrue(SdcUtil.GetPropertyInfo(li).ItemIndex == list.Items.Count() - 1); li.Move(list, 0); Assert.IsTrue(SdcUtil.GetPropertyInfo(li).ItemIndex == 0); li.Move(list); Assert.IsTrue(SdcUtil.GetPropertyInfo(li).ItemIndex == list.Items.Count() - 1); Setup.TimerPrintSeconds(" seconds: ", $"\r\n<=={Setup.CallerName()} Complete"); }