Ejemplo n.º 1
0
        /// <summary>
        /// Add path item (string vector(s))
        /// </summary>
        /// <param name="values">path elements</param>
        /// <returns>this</returns>
        public RestClient AddPath(params string[] values)
        {
            values.Verify(nameof(values)).IsNotNull();

            PathItems = PathItems.With(values);

            return(this);
        }
Ejemplo n.º 2
0
 private void OnFolderSelected(Item item)
 {
     if (item is DirectoryItem directory)
     {
         PathItems.Add(directory);
         Items = new ObservableCollection <Item>(_provider.GetItems(directory.Path));
     }
 }
Ejemplo n.º 3
0
        private void OnMenuItemSelected(DirectoryItem item)
        {
            int index = PathItems.IndexOf(item);

            for (int i = PathItems.Count - 1; i > PathItems.IndexOf(item); i--)
            {
                PathItems.RemoveAt(i);
            }
            Items = new ObservableCollection <Item>(_provider.GetItems(item.Path));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Flag indicating whether the node's PathItems dictionary has operations
        /// under a given label.
        /// </summary>
        /// <param name="label">The name of the key for the target operations
        /// in the node's PathItems dictionary.</param>
        /// <returns>true or false.</returns>
        public bool HasOperations(string label)
        {
            Utils.CheckArgumentNullOrEmpty(label, nameof(label));

            if (!(PathItems?.ContainsKey(label) ?? false))
            {
                return(false);
            }

            return(PathItems[label].Operations?.Any() ?? false);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Add path item (string vector(s))
        /// </summary>
        /// <param name="value">path(s)</param>
        /// <param name="values">additional path(s)</param>
        /// <returns>this</returns>
        public RestClient AddPath(string value, params string[] values)
        {
            Verify.IsNotEmpty(nameof(value), value);

            PathItems = PathItems.With(value);
            if (values != null)
            {
                PathItems = PathItems.With(values);
            }

            return(this);
        }
Ejemplo n.º 6
0
 private void OnPreviousDirectoryRequested()
 {
     if (PathItems.Count > 1)
     {
         PathItems.RemoveAt(PathItems.Count - 1);
         Items = new ObservableCollection <Item>(_provider.GetItems(PathItems.Last().Path));
     }
     else if (PathItems.Count == 1)
     {
         PathItems.Clear();
         Items = new ObservableCollection <Item>(_provider.GetDrives());
     }
 }
Ejemplo n.º 7
0
        public Filepath Combine(PathItems items)
        {
            if (items.Count == 0)
            {
                return(this);
            }

            return(new Filepath
            {
                Prefix = this.Prefix,
                IsAbsolute = this.IsAbsolute,
                Items = this.Items.CombineItems(items),
            });
        }
 public void AddPathItem(object expression, OpenApiPathItem pathItem)
 {
     if (expression == null)
     {
         throw new ArgumentNullException(nameof(expression));
     }
     if (pathItem == null)
     {
         throw new ArgumentNullException(nameof(pathItem));
     }
     if (PathItems == null)
     {
         PathItems = new Dictionary <object, OpenApiPathItem>();
     }
     PathItems.Add(expression, pathItem);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Shifts all selected lines in the PathItems list up or down.
        /// </summary>
        /// <param name="delta">Shift length</param>
        private void ShiftSelectedPathItems(int delta)
        {
            int selectedCount = PathItems.SelectedIndices.Count;

            if (selectedCount == 0)
            {
                return;
            }

            /* Get selected lines' indicies */
            var selected = new int[selectedCount];

            PathItems.SelectedIndices.CopyTo(selected, 0);

            /* Exit if the first selected line is on the top of PathItems list while moving up
             * or when the last selected line is on the bottom of PathItems list while shifting down */
            if ((delta <= 0 && selected[0] == 0) ||
                (delta > 0 && (selected[selectedCount - 1] == 0 ||
                               selected[selectedCount - 1] == PathItems.Items.Count - 1)))
            {
                PathItems.Select();
                return;
            }

            /* Shift all selected lines up */
            int line = (delta > 0) ? (selectedCount - 1) : 0;

            do
            {
                SwapPathItemsLines(selected[line], selected[line] += delta);
                line -= delta;
            }while (line != -1 && line != selectedCount);

            /* Update selected lines */
            PathItems.SelectedItems.Clear();
            foreach (var index in selected)
            {
                PathItems.SelectedIndices.Add(index);
            }

            /* Set the first or last selected line to be visible and have focus */
            PathItems.Select();
            PathItems.Items[selected[0]].Focused = true;
            PathItems.Items[selected[(delta > 0) ? (selectedCount - 1) : 0]].EnsureVisible();

            Changed(true);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Assembles the constituent properties of an <see cref="OpenApiUrlTreeNode"/> node.
        /// </summary>
        /// <param name="segments">IEnumerable subdirectories of a relative path.</param>
        /// <param name="pathItem">Path Item object that describes the operations available on an OpenAPI path.</param>
        /// <param name="label">A name tag for labelling the <see cref="OpenApiUrlTreeNode"/> node.</param>
        /// <param name="currentPath">The relative path of a node.</param>
        /// <returns>An <see cref="OpenApiUrlTreeNode"/> node with all constituent properties assembled.</returns>
        private OpenApiUrlTreeNode Attach(IEnumerable <string> segments,
                                          OpenApiPathItem pathItem,
                                          string label,
                                          string currentPath)
        {
            var segment = segments.FirstOrDefault();

            if (string.IsNullOrEmpty(segment))
            {
                if (PathItems.ContainsKey(label))
                {
                    throw new ArgumentException("A duplicate label already exists for this node.", nameof(label));
                }

                Path = currentPath;
                PathItems.Add(label, pathItem);
                return(this);
            }

            // If the child segment has already been defined, then insert into it
            if (Children.ContainsKey(segment))
            {
                var newPath = currentPath + PathSeparator + segment;

                return(Children[segment].Attach(segments: segments.Skip(1),
                                                pathItem: pathItem,
                                                label: label,
                                                currentPath: newPath));
            }
            else
            {
                var newPath = currentPath + PathSeparator + segment;

                var node = new OpenApiUrlTreeNode(segment)
                {
                    Path = newPath
                };

                Children[segment] = node;

                return(node.Attach(segments: segments.Skip(1),
                                   pathItem: pathItem,
                                   label: label,
                                   currentPath: newPath));
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Add a <see cref="OpenApiPathItem"/> into the <see cref="PathItems"/>.
        /// </summary>
        /// <param name="expression">The runtime expression.</param>
        /// <param name="pathItem">The path item.</param>
        public void AddPathItem(RuntimeExpression expression, OpenApiPathItem pathItem)
        {
            if (expression == null)
            {
                throw Error.ArgumentNull(nameof(expression));
            }

            if (pathItem == null)
            {
                throw Error.ArgumentNull(nameof(pathItem));
            }

            if (PathItems == null)
            {
                PathItems = new Dictionary <RuntimeExpression, OpenApiPathItem>();
            }

            PathItems.Add(expression, pathItem);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Add path item (string vector(s))
 /// </summary>
 /// <param name="values">path elements</param>
 /// <returns>this</returns>
 public RestClient AddPath(params string[] values)
 {
     PathItems = PathItems.With(values);
     return(this);
 }
Ejemplo n.º 13
0
 public void AddPathItem(string key, PathItem pathItem)
 {
     PathItems.Add(key, pathItem);
 }