File size: 1,618 Bytes
8c763fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Collections.Generic;
using System.Management.Automation.Runspaces;
namespace System.Management.Automation
{
/// <summary>
/// Repository of remote runspaces available in a local runspace.
/// </summary>
public class RunspaceRepository : Repository<PSSession>
{
#region Public Methods
/// <summary>
/// Collection of runspaces available.
/// </summary>
public List<PSSession> Runspaces
{
get
{
return Items;
}
}
#endregion Public Methods
#region Internal Methods
/// <summary>
/// Internal constructor.
/// </summary>
internal RunspaceRepository() : base("runspace")
{
}
/// <summary>
/// Gets a key for the specified item.
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
protected override Guid GetKey(PSSession item)
{
if (item != null)
{
return item.InstanceId;
}
return Guid.Empty;
}
/// <summary>
/// Adds the PSSession item to the repository if it doesn't already
/// exist or replaces the existing one.
/// </summary>
/// <param name="item">PSSession object.</param>
internal void AddOrReplace(PSSession item)
{
this.Dictionary[GetKey(item)] = item;
}
#endregion Private Methods
}
}
|