Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
runspacerepository.cs66 linesDownload Raw Back to commands
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4using System.Collections.Generic;5using System.Management.Automation.Runspaces;6 7namespace System.Management.Automation8{9    /// <summary>10    /// Repository of remote runspaces available in a local runspace.11    /// </summary>12    public class RunspaceRepository : Repository<PSSession>13    {14        #region Public Methods15 16        /// <summary>17        /// Collection of runspaces available.18        /// </summary>19        public List<PSSession> Runspaces20        {21            get22            {23                return Items;24            }25        }26 27        #endregion Public Methods28 29        #region Internal Methods30 31        /// <summary>32        /// Internal constructor.33        /// </summary>34        internal RunspaceRepository() : base("runspace")35        {36        }37 38        /// <summary>39        /// Gets a key for the specified item.40        /// </summary>41        /// <param name="item"></param>42        /// <returns></returns>43        protected override Guid GetKey(PSSession item)44        {45            if (item != null)46            {47                return item.InstanceId;48            }49 50            return Guid.Empty;51        }52 53        /// <summary>54        /// Adds the PSSession item to the repository if it doesn't already55        /// exist or replaces the existing one.56        /// </summary>57        /// <param name="item">PSSession object.</param>58        internal void AddOrReplace(PSSession item)59        {60            this.Dictionary[GetKey(item)] = item;61        }62 63        #endregion Private Methods64    }65}66