Esempio n. 1
0
        /// <summary>
        /// Find multiple nodes on the screen
        /// </summary>
        /// <param name="timeout">Timeout in seconds</param>
        /// <param name="with">Find node with</param>
        /// <returns>Returns found node</returns>
        /// <exception cref="UiNodeNotFoundException">If we timeout and can't find any nodes</exception>
        public IList <Node> FindNodes(int timeout, With[] with)
        {
            if (with == null || !with.Any())
            {
                throw new ArgumentException("You must search with at least one \"with\"", nameof(with));
            }

            var startTime = DateTime.Now;

            while (true)
            {
                try
                {
                    UpdateCachedNodes();
                    foreach (var uiExtension in Extensions)
                    {
                        if (uiExtension.CheckNodes(CachedNodes, Device))
                        {
                            startTime = DateTime.Now;
                        }
                    }

                    return(_nodeFinder.FindNodes(CachedNodes, with));
                }
                catch (UiNodeNotFoundException)
                {
                    if ((DateTime.Now - startTime).TotalSeconds > timeout)
                    {
                        throw;
                    }
                }
            }
        }
    public void MoveKeys(JsonObject obj)
    {
        var moving      = Include.FindNodes(obj).ToList();
        var destination = NameNodeMatcher.CreatePath(Destination, obj);

        foreach (var(name, node) in moving)
        {
            node.Parent.AsObject().Remove(name);
            destination.Add(name, node);
        }
    }
    public override void Sort(JsonNode root)
    {
        var selected = Finder.FindNodes(root);

        foreach (var(name, node) in selected)
        {
            if (Matches == null || Matches.Matches(name, node))
            {
                SortSelected(node);
            }
        }
    }