Refactor MultipleServiceCommandBase.AllServices (#15053)

This commit is contained in:
xtqqczze 2021-03-23 17:44:43 +00:00 committed by GitHub
parent 8cc9b114b7
commit b9f378d967
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -290,28 +290,19 @@ namespace Microsoft.PowerShell.Commands
#region Internal
/// <summary>
/// Retrieve the master list of all services.
/// Gets an array of all services.
/// </summary>
/// <value></value>
/// <value>
/// An array of <see cref="ServiceController"/> components that represents all the service resources.
/// </value>
/// <exception cref="System.Security.SecurityException">
/// MSDN does not document the list of exceptions,
/// but it is reasonable to expect that SecurityException is
/// among them. Errors here will terminate the cmdlet.
/// </exception>
internal ServiceController[] AllServices
{
get
{
if (_allServices == null)
{
_allServices = ServiceController.GetServices();
}
internal ServiceController[] AllServices => _allServices ??= ServiceController.GetServices();
return _allServices;
}
}
private ServiceController[] _allServices = null;
private ServiceController[] _allServices;
internal ServiceController GetOneService(string nameOfService)
{