public void VisitorPattern() { ItemElements[] item = new ItemElements[] { new Book(20, "1123"), new Book(50, "125"), new Fruit(20, "Banana", 1), new Fruit(80, "PineApple", 2) }; int total = CalculatePrice(item); Console.WriteLine("Total Price is " + total); }
// for List (except Tree) private void CreateHUDItemsForCollection(ICollection <IHUDItem> container, AutomationElement collection) { var bounds = collection.Current.BoundingRectangle; var treeWalker = new TreeWalker(Condition); var item = treeWalker.GetFirstChild(collection); var beginOnScreen = false; while (item != null) { var aeInfo = item.Current; var rect = aeInfo.BoundingRectangle; if (!IgnoreElements.Contains(aeInfo.ControlType) && bounds.Contains(rect)) { if (!beginOnScreen && ItemElements.Contains(aeInfo.ControlType)) { beginOnScreen = true; } var ct = aeInfo.ControlType; rect.X -= DesktopBounds.Left; rect.Y -= DesktopBounds.Top; AddHUDItem(container, rect); if (!EndElements.Contains(ct)) { _taskList.Enqueue(item); } } else if (beginOnScreen) { break; } item = treeWalker.GetNextSibling(item); } }