Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
StackInfo.cs62 linesDownload Raw Back to namespaces
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4using System.Collections.Generic;5 6namespace System.Management.Automation7{8    /// <summary>9    /// An object that represents a stack of paths.10    /// </summary>11    public sealed class PathInfoStack : Stack<PathInfo>12    {13        /// <summary>14        /// Constructor for the PathInfoStack class.15        /// </summary>16        /// <param name="stackName">17        /// The name of the stack.18        /// </param>19        /// <param name="locationStack">20        /// A stack object containing PathInfo objects21        /// </param>22        /// <exception cref="ArgumentNullException">23        /// If <paramref name="locationStack"/> is null.24        /// </exception>25        /// <exception cref="ArgumentException">26        /// If <paramref name="stackName"/> is null or empty.27        /// </exception>28        internal PathInfoStack(string stackName, Stack<PathInfo> locationStack) : base()29        {30            if (locationStack == null)31            {32                throw PSTraceSource.NewArgumentNullException(nameof(locationStack));33            }34 35            if (string.IsNullOrEmpty(stackName))36            {37                throw PSTraceSource.NewArgumentException(nameof(stackName));38            }39 40            Name = stackName;41 42            // Since the Stack<T> constructor takes an IEnumerable and43            // not a Stack<T> the stack actually gets enumerated in the44            // wrong order.  I have to push them on manually in the45            // appropriate order.46 47            PathInfo[] stackContents = new PathInfo[locationStack.Count];48            locationStack.CopyTo(stackContents, 0);49 50            for (int index = stackContents.Length - 1; index >= 0; --index)51            {52                this.Push(stackContents[index]);53            }54        }55 56        /// <summary>57        /// Gets the name of the stack.58        /// </summary>59        public string Name { get; } = null;60    }61}62