diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/Innerlist.cs b/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/Innerlist.cs index 4f04b09d7a4..28f8be37a4f 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/Innerlist.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/Innerlist.cs @@ -146,7 +146,7 @@ public ObservableCollection Columns { Dispatcher.BeginInvoke( DispatcherPriority.Background, - (DispatcherOperationCallback)delegate(object arg) + (DispatcherOperationCallback)((arg) => { if (this.IsLoaded) { @@ -154,7 +154,7 @@ public ObservableCollection Columns } return null; - }, + }), item); } diff --git a/src/Microsoft.Management.UI.Internal/commandHelpers/HelpWindowHelper.cs b/src/Microsoft.Management.UI.Internal/commandHelpers/HelpWindowHelper.cs index 4c47395c8f3..04e6d74ae69 100644 --- a/src/Microsoft.Management.UI.Internal/commandHelpers/HelpWindowHelper.cs +++ b/src/Microsoft.Management.UI.Internal/commandHelpers/HelpWindowHelper.cs @@ -30,13 +30,13 @@ private static void ShowHelpWindow(PSObject helpObj, PSCmdlet cmdlet) { ownerWindow.Dispatcher.Invoke( new SendOrPostCallback( - delegate(object ignored) + (_) => { HelpWindow helpWindow = new HelpWindow(helpObj); helpWindow.Owner = ownerWindow; helpWindow.Show(); - helpWindow.Closed += new EventHandler(delegate(object sender, EventArgs e) { ownerWindow.Focus(); }); + helpWindow.Closed += new EventHandler((sender, e) => ownerWindow.Focus()); }), string.Empty); return; diff --git a/src/Microsoft.Management.UI.Internal/commandHelpers/OutGridView.cs b/src/Microsoft.Management.UI.Internal/commandHelpers/OutGridView.cs index 8e157d26606..ea36be8c73d 100644 --- a/src/Microsoft.Management.UI.Internal/commandHelpers/OutGridView.cs +++ b/src/Microsoft.Management.UI.Internal/commandHelpers/OutGridView.cs @@ -409,7 +409,7 @@ private void AddColumns(string[] propertyNames, string[] displayNames, Type[] ty this.managementList.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action( - delegate() + () => { // Pick the length of the shortest incoming arrays. Normally all incoming arrays should be of the same length. int length = propertyNames.Length; @@ -461,19 +461,19 @@ private void AddColumns(string[] propertyNames, string[] displayNames, Type[] ty // Set focus on ListView this.managementList.List.SelectedIndex = 0; this.managementList.List.Focus(); - } - catch (Exception e) - { - // Store the exception in a local variable that will be checked later. - if (e.InnerException != null) - { - this.exception = e.InnerException; - } - else - { - this.exception = e; - } - } + } + catch (Exception e) + { + // Store the exception in a local variable that will be checked later. + if (e.InnerException != null) + { + this.exception = e.InnerException; + } + else + { + this.exception = e; + } + } })); } @@ -492,7 +492,7 @@ private void AddItem(PSObject value) this.managementList.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action( - delegate() + () => { try { diff --git a/src/Microsoft.Management.UI.Internal/commandHelpers/ShowCommandHelper.cs b/src/Microsoft.Management.UI.Internal/commandHelpers/ShowCommandHelper.cs index b23cf686d29..95925ff40de 100644 --- a/src/Microsoft.Management.UI.Internal/commandHelpers/ShowCommandHelper.cs +++ b/src/Microsoft.Management.UI.Internal/commandHelpers/ShowCommandHelper.cs @@ -645,7 +645,7 @@ internal static AllModulesViewModel GetNewAllModulesViewModel(AllModulesViewMode } ModuleViewModel moduleToSelect = returnValue.Modules.Find( - new Predicate(delegate(ModuleViewModel module) + new Predicate((module) => { return module.Name.Equals(selectedModuleNeedingImportModule, StringComparison.OrdinalIgnoreCase) ? true : false; })); @@ -658,7 +658,7 @@ internal static AllModulesViewModel GetNewAllModulesViewModel(AllModulesViewMode returnValue.SelectedModule = moduleToSelect; CommandViewModel commandToSelect = moduleToSelect.Commands.Find( - new Predicate(delegate(CommandViewModel command) + new Predicate((command) => { return command.ModuleName.Equals(parentModuleNeedingImportModule, StringComparison.OrdinalIgnoreCase) && command.Name.Equals(commandNeedingImportModule, StringComparison.OrdinalIgnoreCase) ? true : false; @@ -876,11 +876,8 @@ private static void ActivateWindow(Window window) { window.Dispatcher.Invoke( new SendOrPostCallback( - delegate(object ignored) - { - window.Activate(); - }), - string.Empty); + (_) => window.Activate()), + string.Empty); } /// @@ -896,7 +893,7 @@ private static void ActivateWindow(Window window) [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Called using reflection")] private void ShowAllModulesWindow(PSCmdlet cmdlet, Dictionary importedModules, IEnumerable commands, bool noCommonParameter, double windowWidth, double windowHeight, bool passThrough) { - this.methodThatReturnsDialog = new DispatcherOperationCallback(delegate(object ignored) + this.methodThatReturnsDialog = new DispatcherOperationCallback((object ignored) => { ShowAllModulesWindow allModulesWindow = new ShowAllModulesWindow(); this.allModulesViewModel = new AllModulesViewModel(importedModules, commands, noCommonParameter); @@ -939,7 +936,7 @@ private void CallShowDialog(PSCmdlet cmdlet) this.hostWindow.Dispatcher.Invoke( new SendOrPostCallback( - delegate(object ignored) + (_) => { Window childWindow = (Window)this.methodThatReturnsDialog.Invoke(null); childWindow.Owner = this.hostWindow; @@ -967,7 +964,7 @@ private void PlainInvokeAndShowDialog() [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Called using reflection")] private void ShowCommandWindow(PSCmdlet cmdlet, object commandViewModelObj, double windowWidth, double windowHeight, bool passThrough) { - this.methodThatReturnsDialog = new DispatcherOperationCallback(delegate(object ignored) + this.methodThatReturnsDialog = new DispatcherOperationCallback((object ignored) => { this.commandViewModel = (CommandViewModel)commandViewModelObj; ShowCommandWindow showCommandWindow = new ShowCommandWindow(); @@ -1034,7 +1031,7 @@ private void ImportModuleFailed(Exception reason) { this.window.Dispatcher.Invoke( new SendOrPostCallback( - delegate(object ignored) + (_) => { string message = ShowCommandHelper.GetImportModuleFailedMessage( this.commandNeedingImportModule,