From dfd5685d73dcf4e921030650fd4167db9c7ab832 Mon Sep 17 00:00:00 2001 From: xtqqczze Date: Wed, 17 Mar 2021 14:55:52 +0000 Subject: [PATCH] Refactor MultipleServiceCommandBase.AllServices --- .../commands/management/Service.cs | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs index 1d793857c1a..82210f627ce 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs @@ -290,28 +290,19 @@ public ServiceController[] InputObject #region Internal /// - /// Retrieve the master list of all services. + /// Gets an array of all services. /// - /// + /// + /// An array of components that represents all the service resources. + /// /// /// 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. /// - internal ServiceController[] AllServices - { - get - { - if (_allServices == null) - { - _allServices = ServiceController.GetServices(); - } - - return _allServices; - } - } + internal ServiceController[] AllServices => _allServices ??= ServiceController.GetServices(); - private ServiceController[] _allServices = null; + private ServiceController[] _allServices; internal ServiceController GetOneService(string nameOfService) {