diff --git a/src/Microsoft.Management.Infrastructure.CimCmdlets/RegisterCimIndicationCommand.cs b/src/Microsoft.Management.Infrastructure.CimCmdlets/RegisterCimIndicationCommand.cs index 8e2e6ae27fd..de7bd63feae 100644 --- a/src/Microsoft.Management.Infrastructure.CimCmdlets/RegisterCimIndicationCommand.cs +++ b/src/Microsoft.Management.Infrastructure.CimCmdlets/RegisterCimIndicationCommand.cs @@ -257,7 +257,7 @@ protected override void EndProcessing() if (newSubscriber != null) { DebugHelper.WriteLog("RegisterCimIndicationCommand::EndProcessing subscribe to Unsubscribed event", 4); - newSubscriber.Unsubscribed += new PSEventUnsubscribedEventHandler(newSubscriber_Unsubscribed); + newSubscriber.Unsubscribed += newSubscriber_Unsubscribed; } } diff --git a/src/Microsoft.Management.UI.Internal/HelpWindow/HelpViewModel.cs b/src/Microsoft.Management.UI.Internal/HelpWindow/HelpViewModel.cs index 1b8ee0e8400..7cbe4b0c74e 100644 --- a/src/Microsoft.Management.UI.Internal/HelpWindow/HelpViewModel.cs +++ b/src/Microsoft.Management.UI.Internal/HelpWindow/HelpViewModel.cs @@ -61,7 +61,7 @@ internal HelpViewModel(PSObject psObj, Paragraph documentParagraph) this.helpBuilder = new HelpParagraphBuilder(documentParagraph, psObj); this.helpBuilder.BuildParagraph(); this.searcher = new ParagraphSearcher(); - this.helpBuilder.PropertyChanged += new PropertyChangedEventHandler(this.HelpBuilder_PropertyChanged); + this.helpBuilder.PropertyChanged += this.HelpBuilder_PropertyChanged; this.helpTitle = string.Format( CultureInfo.CurrentCulture, HelpWindowResources.HelpTitleFormat, diff --git a/src/Microsoft.Management.UI.Internal/HelpWindow/HelpWindow.xaml.cs b/src/Microsoft.Management.UI.Internal/HelpWindow/HelpWindow.xaml.cs index a2a23e13900..6793806503a 100644 --- a/src/Microsoft.Management.UI.Internal/HelpWindow/HelpWindow.xaml.cs +++ b/src/Microsoft.Management.UI.Internal/HelpWindow/HelpWindow.xaml.cs @@ -74,11 +74,11 @@ public HelpWindow(PSObject helpObject) this.ReadZoomUserSetting(); - this.viewModel.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.ViewModel_PropertyChanged); + this.viewModel.PropertyChanged += this.ViewModel_PropertyChanged; this.DataContext = this.viewModel; - this.Loaded += new RoutedEventHandler(this.HelpDialog_Loaded); - this.Closed += new System.EventHandler(this.HelpDialog_Closed); + this.Loaded += this.HelpDialog_Loaded; + this.Closed += this.HelpDialog_Closed; } /// @@ -222,9 +222,9 @@ private void HelpDialog_StateChanged(object sender, System.EventArgs e) /// Event arguments. private void HelpDialog_Loaded(object sender, RoutedEventArgs e) { - this.StateChanged += new System.EventHandler(this.HelpDialog_StateChanged); - this.LocationChanged += new System.EventHandler(this.HelpDialog_LocationChanged); - this.SizeChanged += new SizeChangedEventHandler(this.HelpDialog_SizeChanged); + this.StateChanged += this.HelpDialog_StateChanged; + this.LocationChanged += this.HelpDialog_LocationChanged; + this.SizeChanged += this.HelpDialog_SizeChanged; } /// diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/Common/ListOrganizerItem.cs b/src/Microsoft.Management.UI.Internal/ManagementList/Common/ListOrganizerItem.cs index ddcb75df521..469ed5aec77 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/Common/ListOrganizerItem.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/Common/ListOrganizerItem.cs @@ -46,7 +46,7 @@ public void Select() { if (!this.IsLoaded) { - this.Loaded += new RoutedEventHandler(this.ListOrganizerItem_Loaded_SelectItem); + this.Loaded += this.ListOrganizerItem_Loaded_SelectItem; this.ApplyTemplate(); return; } @@ -189,7 +189,7 @@ private void UpdateTextContentBindings() { if (!this.IsLoaded) { - this.Loaded += new RoutedEventHandler(this.ListOrganizerItem_Loaded_UpdateTextContentBindings); + this.Loaded += this.ListOrganizerItem_Loaded_UpdateTextContentBindings; this.ApplyTemplate(); return; } @@ -230,13 +230,13 @@ partial void PostOnApplyTemplate() private void AttachToVisualTree() { this.editBox.IsVisibleChanged += new DependencyPropertyChangedEventHandler(this.EditBox_IsVisibleChanged); - this.editBox.KeyDown += new KeyEventHandler(this.EditBox_KeyDown); - this.editBox.LostFocus += new RoutedEventHandler(this.EditBox_LostFocus); + this.editBox.KeyDown += this.EditBox_KeyDown; + this.editBox.LostFocus += this.EditBox_LostFocus; this.templatedParent = this.TemplatedParent as FrameworkElement; if (this.templatedParent != null) { - this.templatedParent.KeyDown += new KeyEventHandler(this.TemplatedParent_OnKeyDown); + this.templatedParent.KeyDown += this.TemplatedParent_OnKeyDown; } } diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/Common/PickerBase.cs b/src/Microsoft.Management.UI.Internal/ManagementList/Common/PickerBase.cs index 271f5f3a279..bb4b6c61511 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/Common/PickerBase.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/Common/PickerBase.cs @@ -47,7 +47,7 @@ private void ApplyDropDownButtonTemplate() if (!this.IsLoaded) { this.ApplyTemplate(); - this.Loaded += new RoutedEventHandler(this.PickerBase_Loaded_ApplyDropDownButtonTemplate); + this.Loaded += this.PickerBase_Loaded_ApplyDropDownButtonTemplate; return; } @@ -76,7 +76,7 @@ private void FocusDropDown() { if (!this.dropDown.IsLoaded) { - this.dropDown.Loaded += new RoutedEventHandler(this.DropDown_Loaded_FocusDropDown); + this.dropDown.Loaded += this.DropDown_Loaded_FocusDropDown; } if (this.dropDown.Child != null && !this.dropDown.IsAncestorOf((DependencyObject)Keyboard.FocusedElement)) @@ -116,8 +116,8 @@ partial void PreOnApplyTemplate() private void AttachToVisualTree() { - this.dropDown.Opened += new EventHandler(this.DropDown_Opened); - this.dropDown.Closed += new EventHandler(this.DropDown_Closed); + this.dropDown.Opened += this.DropDown_Opened; + this.dropDown.Closed += this.DropDown_Closed; } private void DetachFromVisualTree() diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/Common/ReadOnlyObservableAsyncCollection.cs b/src/Microsoft.Management.UI.Internal/ManagementList/Common/ReadOnlyObservableAsyncCollection.cs index cf183fa01f2..7734bc4903c 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/Common/ReadOnlyObservableAsyncCollection.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/Common/ReadOnlyObservableAsyncCollection.cs @@ -34,8 +34,8 @@ public ReadOnlyObservableAsyncCollection(IList list) { this.asyncProgress = list as IAsyncProgress; - ((INotifyCollectionChanged)this.Items).CollectionChanged += new NotifyCollectionChangedEventHandler(this.HandleCollectionChanged); - ((INotifyPropertyChanged)this.Items).PropertyChanged += new PropertyChangedEventHandler(this.HandlePropertyChanged); + ((INotifyCollectionChanged)this.Items).CollectionChanged += this.HandleCollectionChanged; + ((INotifyPropertyChanged)this.Items).PropertyChanged += this.HandlePropertyChanged; } #endregion Constructors diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/Common/WpfHelp.cs b/src/Microsoft.Management.UI.Internal/ManagementList/Common/WpfHelp.cs index 055e6453c22..23ff80d9974 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/Common/WpfHelp.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/Common/WpfHelp.cs @@ -65,7 +65,7 @@ public static bool RetryActionAfterLoaded(FrameworkElement element, RetryActi data.Enqueue(callback, parameter); - element.Loaded += new RoutedEventHandler(Element_Loaded); + element.Loaded += Element_Loaded; element.ApplyTemplate(); return true; diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterEvaluator.cs b/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterEvaluator.cs index 3a2a3c71585..2b33153a983 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterEvaluator.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterEvaluator.cs @@ -151,7 +151,7 @@ public void AddFilterExpressionProvider(IFilterExpressionProvider provider) } this.filterExpressionProviders.Add(provider); - provider.FilterExpressionChanged += new EventHandler(this.FilterProvider_FilterExpressionChanged); + provider.FilterExpressionChanged += this.FilterProvider_FilterExpressionChanged; } /// @@ -168,7 +168,7 @@ public void RemoveFilterExpressionProvider(IFilterExpressionProvider provider) } this.filterExpressionProviders.Remove(provider); - provider.FilterExpressionChanged -= new EventHandler(this.FilterProvider_FilterExpressionChanged); + provider.FilterExpressionChanged -= this.FilterProvider_FilterExpressionChanged; } #region NotifyPropertyChanged diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/IsBetweenFilterRule.cs b/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/IsBetweenFilterRule.cs index 8765e033920..b54508157a6 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/IsBetweenFilterRule.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/IsBetweenFilterRule.cs @@ -63,10 +63,10 @@ public IsBetweenFilterRule() this.DisplayName = UICultureResources.FilterRule_IsBetween; this.StartValue = new ValidatingValue(); - this.StartValue.PropertyChanged += new PropertyChangedEventHandler(this.Value_PropertyChanged); + this.StartValue.PropertyChanged += this.Value_PropertyChanged; this.EndValue = new ValidatingValue(); - this.EndValue.PropertyChanged += new PropertyChangedEventHandler(this.Value_PropertyChanged); + this.EndValue.PropertyChanged += this.Value_PropertyChanged; } #endregion Ctor @@ -111,8 +111,8 @@ private void Value_PropertyChanged(object sender, PropertyChangedEventArgs e) [OnDeserialized] private void Initialize(StreamingContext context) { - this.StartValue.PropertyChanged += new PropertyChangedEventHandler(this.Value_PropertyChanged); - this.EndValue.PropertyChanged += new PropertyChangedEventHandler(this.Value_PropertyChanged); + this.StartValue.PropertyChanged += this.Value_PropertyChanged; + this.EndValue.PropertyChanged += this.Value_PropertyChanged; } #endregion Value Change Handlers diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/PropertiesTextContainsFilterRule.cs b/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/PropertiesTextContainsFilterRule.cs index 984d378dfdf..c29715419ce 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/PropertiesTextContainsFilterRule.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/PropertiesTextContainsFilterRule.cs @@ -26,7 +26,7 @@ public class PropertiesTextContainsFilterRule : TextFilterRule public PropertiesTextContainsFilterRule() { this.PropertyNames = new List(); - this.EvaluationResultInvalidated += new EventHandler(this.PropertiesTextContainsFilterRule_EvaluationResultInvalidated); + this.EvaluationResultInvalidated += this.PropertiesTextContainsFilterRule_EvaluationResultInvalidated; } /// @@ -124,7 +124,7 @@ private void PropertiesTextContainsFilterRule_EvaluationResultInvalidated(object [OnDeserialized] private void Initialize(StreamingContext context) { - this.EvaluationResultInvalidated += new EventHandler(this.PropertiesTextContainsFilterRule_EvaluationResultInvalidated); + this.EvaluationResultInvalidated += this.PropertiesTextContainsFilterRule_EvaluationResultInvalidated; } } } diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/SelectorFilterRule.cs b/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/SelectorFilterRule.cs index be4c516eb0f..c67b1c993e5 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/SelectorFilterRule.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/SelectorFilterRule.cs @@ -45,7 +45,7 @@ public ValidatingSelectorValue AvailableRules public SelectorFilterRule() { this.AvailableRules = new ValidatingSelectorValue(); - this.AvailableRules.SelectedValueChanged += new EventHandler>(this.AvailableRules_SelectedValueChanged); + this.AvailableRules.SelectedValueChanged += this.AvailableRules_SelectedValueChanged; } #endregion Ctor @@ -86,8 +86,8 @@ protected void OnSelectedValueChanged(FilterRule oldValue, FilterRule newValue) FilterRuleCustomizationFactory.FactoryInstance.TransferValues(oldValue, newValue); FilterRuleCustomizationFactory.FactoryInstance.ClearValues(oldValue); - newValue.EvaluationResultInvalidated += new EventHandler(this.SelectedValue_EvaluationResultInvalidated); - oldValue.EvaluationResultInvalidated -= new EventHandler(this.SelectedValue_EvaluationResultInvalidated); + newValue.EvaluationResultInvalidated += this.SelectedValue_EvaluationResultInvalidated; + oldValue.EvaluationResultInvalidated -= this.SelectedValue_EvaluationResultInvalidated; this.NotifyEvaluationResultInvalidated(); } @@ -104,8 +104,8 @@ private void SelectedValue_EvaluationResultInvalidated(object sender, EventArgs [OnDeserialized] private void Initialize(StreamingContext context) { - this.AvailableRules.SelectedValueChanged += new EventHandler>(this.AvailableRules_SelectedValueChanged); - this.AvailableRules.SelectedValue.EvaluationResultInvalidated += new EventHandler(this.SelectedValue_EvaluationResultInvalidated); + this.AvailableRules.SelectedValueChanged += this.AvailableRules_SelectedValueChanged; + this.AvailableRules.SelectedValue.EvaluationResultInvalidated += this.SelectedValue_EvaluationResultInvalidated; } private void AvailableRules_SelectedValueChanged(object sender, PropertyChangedEventArgs e) diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/SingleValueComparableValueFilterRule.cs b/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/SingleValueComparableValueFilterRule.cs index c5902a7901f..5aaabe58bfb 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/SingleValueComparableValueFilterRule.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/FilterCore/FilterRules/SingleValueComparableValueFilterRule.cs @@ -49,7 +49,7 @@ public override bool IsValid protected SingleValueComparableValueFilterRule() { this.Value = new ValidatingValue(); - this.Value.PropertyChanged += new PropertyChangedEventHandler(this.Value_PropertyChanged); + this.Value.PropertyChanged += this.Value_PropertyChanged; } #endregion Ctor @@ -65,7 +65,7 @@ private void Value_PropertyChanged(object sender, PropertyChangedEventArgs e) [OnDeserialized] private void Initialize(StreamingContext context) { - this.Value.PropertyChanged += new PropertyChangedEventHandler(this.Value_PropertyChanged); + this.Value.PropertyChanged += this.Value_PropertyChanged; } } } diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/FilterProviders/FilterRulePanel.cs b/src/Microsoft.Management.UI.Internal/ManagementList/FilterProviders/FilterRulePanel.cs index 1d5e1324942..bcc9a01a92c 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/FilterProviders/FilterRulePanel.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/FilterProviders/FilterRulePanel.cs @@ -133,7 +133,7 @@ public FilterRulePanel() { this.InitializeTemplates(); - this.Controller.FilterExpressionChanged += new EventHandler(this.Controller_FilterExpressionChanged); + this.Controller.FilterExpressionChanged += this.Controller_FilterExpressionChanged; } #endregion Ctor diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/FilterProviders/FilterRulePanelController.cs b/src/Microsoft.Management.UI.Internal/ManagementList/FilterProviders/FilterRulePanelController.cs index 63c611ce66f..dcec5022d98 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/FilterProviders/FilterRulePanelController.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/FilterProviders/FilterRulePanelController.cs @@ -96,7 +96,7 @@ public void AddFilterRulePanelItem(FilterRulePanelItem item) int insertionIndex = this.GetInsertionIndex(item); this.filterRulePanelItems.Insert(insertionIndex, item); - item.Rule.EvaluationResultInvalidated += new EventHandler(this.Rule_EvaluationResultInvalidated); + item.Rule.EvaluationResultInvalidated += this.Rule_EvaluationResultInvalidated; this.UpdateFilterRulePanelItemTypes(); @@ -121,7 +121,7 @@ public void RemoveFilterRulePanelItem(FilterRulePanelItem item) throw new ArgumentNullException("item"); } - item.Rule.EvaluationResultInvalidated -= new EventHandler(this.Rule_EvaluationResultInvalidated); + item.Rule.EvaluationResultInvalidated -= this.Rule_EvaluationResultInvalidated; this.filterRulePanelItems.Remove(item); this.UpdateFilterRulePanelItemTypes(); diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/InnerListGridView.cs b/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/InnerListGridView.cs index e5c0dcaeff2..73222cae639 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/InnerListGridView.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/InnerListGridView.cs @@ -54,8 +54,8 @@ internal InnerListGridView(ObservableCollection availableColumn this.AvailableColumns = availableColumns; this.AvailableColumns_CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, availableColumns)); - availableColumns.CollectionChanged += new NotifyCollectionChangedEventHandler(this.AvailableColumns_CollectionChanged); - this.Columns.CollectionChanged += new NotifyCollectionChangedEventHandler(this.Columns_CollectionChanged); + availableColumns.CollectionChanged += this.AvailableColumns_CollectionChanged; + this.Columns.CollectionChanged += this.Columns_CollectionChanged; } /// diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/Innerlist.cs b/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/Innerlist.cs index 9facdf94ca8..03c7acdf008 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/Innerlist.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/Innerlist.cs @@ -543,8 +543,8 @@ internal void SetColumnHeaderActions() if (header != null) { // header Click - header.Click += new RoutedEventHandler(this.Header_Click); - header.PreviewKeyDown += new KeyEventHandler(this.Header_KeyDown); + header.Click += this.Header_Click; + header.PreviewKeyDown += this.Header_KeyDown; } // If it is a GridViewColumnHeader we will not have the same nice sorting and grouping @@ -695,7 +695,7 @@ private bool SetColumnPickerContextMenuItem() MenuItem columnPicker = new MenuItem(); AutomationProperties.SetAutomationId(columnPicker, "ChooseColumns"); columnPicker.Header = UICultureResources.ColumnPicker; - columnPicker.Click += new RoutedEventHandler(this.innerGrid.OnColumnPicker); + columnPicker.Click += this.innerGrid.OnColumnPicker; this.contextMenu.Items.Add(columnPicker); diff --git a/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/managementlist.cs b/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/managementlist.cs index 9dcd8d9d18b..7c36244e0f1 100644 --- a/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/managementlist.cs +++ b/src/Microsoft.Management.UI.Internal/ManagementList/ManagementList/managementlist.cs @@ -128,16 +128,16 @@ partial void OnEvaluatorChangedImplementation(PropertyChangedEventArgs diff --git a/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ImageButton/ImageToggleButton.xaml.cs b/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ImageButton/ImageToggleButton.xaml.cs index d1e27f3de51..adc1e1a6421 100644 --- a/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ImageButton/ImageToggleButton.xaml.cs +++ b/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ImageButton/ImageToggleButton.xaml.cs @@ -25,7 +25,7 @@ public partial class ImageToggleButton : ImageButtonBase public ImageToggleButton() { InitializeComponent(); - this.Loaded += new System.Windows.RoutedEventHandler(this.ImageButton_Loaded); + this.Loaded += this.ImageButton_Loaded; } /// diff --git a/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ParameterSetControl.xaml.cs b/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ParameterSetControl.xaml.cs index a98c7e6d95b..c258a2819ac 100644 --- a/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ParameterSetControl.xaml.cs +++ b/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ParameterSetControl.xaml.cs @@ -224,7 +224,7 @@ private static TextBox CreateTextBoxControl(ParameterViewModel parameterViewMode textBox.AcceptsReturn = true; textBox.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; textBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; - textBox.Loaded += new RoutedEventHandler(ParameterSetControl.MultiLineTextBox_Loaded); + textBox.Loaded += ParameterSetControl.MultiLineTextBox_Loaded; } return textBox; @@ -238,7 +238,7 @@ private static TextBox CreateTextBoxControl(ParameterViewModel parameterViewMode private static void MultiLineTextBox_Loaded(object sender, RoutedEventArgs e) { TextBox senderTextBox = (TextBox)sender; - senderTextBox.Loaded -= new RoutedEventHandler(ParameterSetControl.MultiLineTextBox_Loaded); + senderTextBox.Loaded -= ParameterSetControl.MultiLineTextBox_Loaded; // This will set the height to about 3 lines since the total height of the // TextBox is a bit greater than a line's height diff --git a/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ShowModuleControl.xaml.cs b/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ShowModuleControl.xaml.cs index c42bdb949bd..440eb329f39 100644 --- a/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ShowModuleControl.xaml.cs +++ b/src/Microsoft.Management.UI.Internal/ShowCommand/Controls/ShowModuleControl.xaml.cs @@ -26,10 +26,10 @@ public ShowModuleControl() InitializeComponent(); // See comment in method summary to understand why this event is handled - this.CommandList.PreviewMouseMove += new MouseEventHandler(this.CommandList_PreviewMouseMove); + this.CommandList.PreviewMouseMove += this.CommandList_PreviewMouseMove; // See comment in method summary to understand why this event is handled - this.CommandList.SelectionChanged += new SelectionChangedEventHandler(this.CommandList_SelectionChanged); + this.CommandList.SelectionChanged += this.CommandList_SelectionChanged; } /// diff --git a/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/AllModulesViewModel.cs b/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/AllModulesViewModel.cs index 9187673a71c..34159c8f837 100644 --- a/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/AllModulesViewModel.cs +++ b/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/AllModulesViewModel.cs @@ -239,10 +239,10 @@ public ModuleViewModel SelectedModule if (this.selectedModule != null) { - this.selectedModule.SelectedCommandNeedsImportModule -= new EventHandler(this.SelectedModule_SelectedCommandNeedsImportModule); - this.selectedModule.SelectedCommandNeedsHelp -= new EventHandler(this.SelectedModule_SelectedCommandNeedsHelp); - this.selectedModule.RunSelectedCommand -= new EventHandler(this.SelectedModule_RunSelectedCommand); - this.selectedModule.PropertyChanged -= new PropertyChangedEventHandler(this.SelectedModule_PropertyChanged); + this.selectedModule.SelectedCommandNeedsImportModule -= this.SelectedModule_SelectedCommandNeedsImportModule; + this.selectedModule.SelectedCommandNeedsHelp -= this.SelectedModule_SelectedCommandNeedsHelp; + this.selectedModule.RunSelectedCommand -= this.SelectedModule_RunSelectedCommand; + this.selectedModule.PropertyChanged -= this.SelectedModule_PropertyChanged; } this.selectedModule = value; @@ -252,10 +252,10 @@ public ModuleViewModel SelectedModule if (this.selectedModule != null) { this.selectedModule.RefreshFilteredCommands(this.CommandNameFilter); - this.selectedModule.SelectedCommandNeedsImportModule += new EventHandler(this.SelectedModule_SelectedCommandNeedsImportModule); - this.selectedModule.SelectedCommandNeedsHelp += new EventHandler(this.SelectedModule_SelectedCommandNeedsHelp); - this.selectedModule.RunSelectedCommand += new EventHandler(this.SelectedModule_RunSelectedCommand); - this.selectedModule.PropertyChanged += new PropertyChangedEventHandler(this.SelectedModule_PropertyChanged); + this.selectedModule.SelectedCommandNeedsImportModule += this.SelectedModule_SelectedCommandNeedsImportModule; + this.selectedModule.SelectedCommandNeedsHelp += this.SelectedModule_SelectedCommandNeedsHelp; + this.selectedModule.RunSelectedCommand += this.SelectedModule_RunSelectedCommand; + this.selectedModule.PropertyChanged += this.SelectedModule_PropertyChanged; this.selectedModule.SelectedCommand = null; } diff --git a/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/CommandViewModel.cs b/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/CommandViewModel.cs index 75263082d29..a098185095c 100644 --- a/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/CommandViewModel.cs +++ b/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/CommandViewModel.cs @@ -168,13 +168,13 @@ public ParameterSetViewModel SelectedParameterSet { if (this.selectedParameterSet != null) { - this.selectedParameterSet.PropertyChanged -= new PropertyChangedEventHandler(this.SelectedParameterSet_PropertyChanged); + this.selectedParameterSet.PropertyChanged -= this.SelectedParameterSet_PropertyChanged; } this.selectedParameterSet = value; if (this.selectedParameterSet != null) { - this.selectedParameterSet.PropertyChanged += new PropertyChangedEventHandler(this.SelectedParameterSet_PropertyChanged); + this.selectedParameterSet.PropertyChanged += this.SelectedParameterSet_PropertyChanged; this.SelectedParameterSetAllMandatoryParametersHaveValues = this.SelectedParameterSet.AllMandatoryParametersHaveValues; } else diff --git a/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/ModuleViewModel.cs b/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/ModuleViewModel.cs index 749b3c56ac4..38925e458a9 100644 --- a/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/ModuleViewModel.cs +++ b/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/ModuleViewModel.cs @@ -188,9 +188,9 @@ public CommandViewModel SelectedCommand if (this.selectedCommand != null) { - this.selectedCommand.PropertyChanged -= new PropertyChangedEventHandler(this.SelectedCommand_PropertyChanged); - this.selectedCommand.HelpNeeded -= new EventHandler(this.SelectedCommand_HelpNeeded); - this.selectedCommand.ImportModule -= new EventHandler(this.SelectedCommand_ImportModule); + this.selectedCommand.PropertyChanged -= this.SelectedCommand_PropertyChanged; + this.selectedCommand.HelpNeeded -= this.SelectedCommand_HelpNeeded; + this.selectedCommand.ImportModule -= this.SelectedCommand_ImportModule; } this.selectedCommand = value; @@ -199,9 +199,9 @@ public CommandViewModel SelectedCommand if (this.selectedCommand != null) { - this.selectedCommand.PropertyChanged += new PropertyChangedEventHandler(this.SelectedCommand_PropertyChanged); - this.selectedCommand.HelpNeeded += new EventHandler(this.SelectedCommand_HelpNeeded); - this.selectedCommand.ImportModule += new EventHandler(this.SelectedCommand_ImportModule); + this.selectedCommand.PropertyChanged += this.SelectedCommand_PropertyChanged; + this.selectedCommand.HelpNeeded += this.SelectedCommand_HelpNeeded; + this.selectedCommand.ImportModule += this.SelectedCommand_ImportModule; this.IsThereASelectedCommand = true; } else diff --git a/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/ParameterSetViewModel.cs b/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/ParameterSetViewModel.cs index d6c8a365d83..756f58c62c8 100644 --- a/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/ParameterSetViewModel.cs +++ b/src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/ParameterSetViewModel.cs @@ -66,7 +66,7 @@ public ParameterSetViewModel( continue; } - parameter.PropertyChanged += new PropertyChangedEventHandler(this.MandatoryParameter_PropertyChanged); + parameter.PropertyChanged += this.MandatoryParameter_PropertyChanged; } this.EvaluateAllMandatoryParametersHaveValues(); diff --git a/src/Microsoft.Management.UI.Internal/ShowCommand/Windows/ShowAllModulesWindow.xaml.cs b/src/Microsoft.Management.UI.Internal/ShowCommand/Windows/ShowAllModulesWindow.xaml.cs index 12436d2f725..b644264376b 100644 --- a/src/Microsoft.Management.UI.Internal/ShowCommand/Windows/ShowAllModulesWindow.xaml.cs +++ b/src/Microsoft.Management.UI.Internal/ShowCommand/Windows/ShowAllModulesWindow.xaml.cs @@ -49,10 +49,10 @@ public ShowAllModulesWindow() this.AllModulesControl.ShowModuleControl.Owner = this; } - this.SizeChanged += new SizeChangedEventHandler(this.ShowAllModulesWindow_SizeChanged); - this.LocationChanged += new System.EventHandler(this.ShowAllModulesWindow_LocationChanged); - this.StateChanged += new System.EventHandler(this.ShowAllModulesWindow_StateChanged); - this.Loaded += new RoutedEventHandler(this.ShowAllModulesWindow_Loaded); + this.SizeChanged += this.ShowAllModulesWindow_SizeChanged; + this.LocationChanged += this.ShowAllModulesWindow_LocationChanged; + this.StateChanged += this.ShowAllModulesWindow_StateChanged; + this.Loaded += this.ShowAllModulesWindow_Loaded; RoutedCommand plusSettings = new RoutedCommand(); KeyGestureConverter keyGestureConverter = new KeyGestureConverter(); diff --git a/src/Microsoft.Management.UI.Internal/ShowCommand/Windows/ShowCommandWindow.xaml.cs b/src/Microsoft.Management.UI.Internal/ShowCommand/Windows/ShowCommandWindow.xaml.cs index 770bc8d8cae..c03a42ed864 100644 --- a/src/Microsoft.Management.UI.Internal/ShowCommand/Windows/ShowCommandWindow.xaml.cs +++ b/src/Microsoft.Management.UI.Internal/ShowCommand/Windows/ShowCommandWindow.xaml.cs @@ -20,9 +20,9 @@ public partial class ShowCommandWindow : Window public ShowCommandWindow() { this.InitializeComponent(); - this.SizeChanged += new SizeChangedEventHandler(this.ShowCommandWindow_SizeChanged); - this.LocationChanged += new System.EventHandler(this.ShowCommandWindow_LocationChanged); - this.StateChanged += new System.EventHandler(this.ShowCommandWindow_StateChanged); + this.SizeChanged += this.ShowCommandWindow_SizeChanged; + this.LocationChanged += this.ShowCommandWindow_LocationChanged; + this.StateChanged += this.ShowCommandWindow_StateChanged; } /// diff --git a/src/Microsoft.Management.UI.Internal/commandHelpers/OutGridView.cs b/src/Microsoft.Management.UI.Internal/commandHelpers/OutGridView.cs index 39405953f33..85ecd95a36f 100644 --- a/src/Microsoft.Management.UI.Internal/commandHelpers/OutGridView.cs +++ b/src/Microsoft.Management.UI.Internal/commandHelpers/OutGridView.cs @@ -135,10 +135,10 @@ private void StartWindow(string invocation, string outputModeOptions, AutoResetE { this.gridViewWindow = new Window(); this.managementList = CreateManagementList(outputModeOptions); - this.gridViewWindow.Loaded += new RoutedEventHandler(this.GridViewWindowLoaded); + this.gridViewWindow.Loaded += this.GridViewWindowLoaded; this.gridViewWindow.Content = CreateMainGrid(outputModeOptions); this.gridViewWindow.Title = invocation; - this.gridViewWindow.Closed += new EventHandler(this.GridViewWindowClosed); + this.gridViewWindow.Closed += this.GridViewWindowClosed; RoutedCommand plusSettings = new RoutedCommand(); KeyGestureConverter keyGestureConverter = new KeyGestureConverter(); @@ -323,7 +323,7 @@ private Button CreateOKButton() ok.SetValue(Grid.ColumnProperty, 0); ok.IsDefault = true; ok.SetValue(AutomationProperties.AutomationIdProperty, "OGVOK"); - ok.Click += new RoutedEventHandler(OK_Click); + ok.Click += OK_Click; return ok; } @@ -340,7 +340,7 @@ private Button CreateCancelButton() cancel.SetValue(Grid.ColumnProperty, 1); cancel.IsCancel = true; cancel.SetValue(AutomationProperties.AutomationIdProperty, "OGVCancel"); - cancel.Click += new RoutedEventHandler(Cancel_Click); + cancel.Click += Cancel_Click; return cancel; } diff --git a/src/Microsoft.Management.UI.Internal/commandHelpers/ShowCommandHelper.cs b/src/Microsoft.Management.UI.Internal/commandHelpers/ShowCommandHelper.cs index 2f66687d9e2..5d401fc94c6 100644 --- a/src/Microsoft.Management.UI.Internal/commandHelpers/ShowCommandHelper.cs +++ b/src/Microsoft.Management.UI.Internal/commandHelpers/ShowCommandHelper.cs @@ -965,7 +965,7 @@ private void ShowCommandWindow(PSCmdlet cmdlet, object commandViewModelObj, doub this.commandViewModel = (CommandViewModel)commandViewModelObj; ShowCommandWindow showCommandWindow = new ShowCommandWindow(); - this.commandViewModel.HelpNeeded += new EventHandler(this.CommandNeedsHelp); + this.commandViewModel.HelpNeeded += this.CommandNeedsHelp; showCommandWindow.DataContext = this.commandViewModel; this.SetupButtonEvents(showCommandWindow.Run, showCommandWindow.Copy, showCommandWindow.Cancel, passThrough); @@ -1097,8 +1097,8 @@ private string GetScript() private void SetupWindow(Window commandWindow) { this.window = commandWindow; - this.window.Closed += new EventHandler(this.Window_Closed); - this.window.Loaded += new RoutedEventHandler(this.Window_Loaded); + this.window.Closed += this.Window_Closed; + this.window.Loaded += this.Window_Loaded; } /// @@ -1149,7 +1149,7 @@ private void Window_Closed(object sender, EventArgs e) /// Event arguments. private void Window_Loaded(object sender, RoutedEventArgs e) { - this.window.Loaded -= new RoutedEventHandler(this.Window_Loaded); + this.window.Loaded -= this.Window_Loaded; this.windowLoaded.Set(); } @@ -1168,9 +1168,9 @@ private void SetupButtonEvents(Button run, Button copy, Button cancel, bool pass run.Content = ShowCommandResources.ActionButtons_Button_Ok; } - run.Click += new RoutedEventHandler(this.Buttons_RunClick); - copy.Click += new RoutedEventHandler(this.Buttons_CopyClick); - cancel.Click += new RoutedEventHandler(this.Buttons_CancelClick); + run.Click += this.Buttons_RunClick; + copy.Click += this.Buttons_CopyClick; + cancel.Click += this.Buttons_CancelClick; } /// @@ -1178,8 +1178,8 @@ private void SetupButtonEvents(Button run, Button copy, Button cancel, bool pass /// private void SetupViewModel() { - this.allModulesViewModel.SelectedCommandInSelectedModuleNeedsHelp += new EventHandler(this.CommandNeedsHelp); - this.allModulesViewModel.SelectedCommandInSelectedModuleNeedsImportModule += new EventHandler(this.CommandNeedsImportModule); + this.allModulesViewModel.SelectedCommandInSelectedModuleNeedsHelp += this.CommandNeedsHelp; + this.allModulesViewModel.SelectedCommandInSelectedModuleNeedsImportModule += this.CommandNeedsImportModule; this.window.DataContext = this.allModulesViewModel; } diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs index 91665575118..3b8713d52b0 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs @@ -1000,7 +1000,7 @@ protected override void EndProcessing() if (!process.HasExited) { process.EnableRaisingEvents = true; - process.Exited += new EventHandler(myProcess_Exited); + process.Exited += myProcess_Exited; if (!process.HasExited) { System.Threading.Interlocked.Increment(ref _numberOfProcessesToWaitFor); @@ -2040,7 +2040,7 @@ protected override void BeginProcessing() else if (!process.HasExited) { // WinBlue: 27537 Start-Process -Wait doesn't work in a remote session on Windows 7 or lower. - process.Exited += new EventHandler(myProcess_Exited); + process.Exited += myProcess_Exited; process.EnableRaisingEvents = true; process.WaitForExit(); } diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs index 44ad59579d2..4b535d279ed 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs @@ -579,7 +579,7 @@ public void PushRunspace(Runspace newRunspace) RemoteRunspace remoteRunspace = newRunspace as RemoteRunspace; Dbg.Assert(remoteRunspace != null, "Expected remoteRunspace != null"); - remoteRunspace.StateChanged += new EventHandler(HandleRemoteRunspaceStateChanged); + remoteRunspace.StateChanged += HandleRemoteRunspaceStateChanged; // Unsubscribe the local session debugger. if (_runspaceRef.Runspace.Debugger != null) @@ -2375,8 +2375,8 @@ private InputLoop(ConsoleHost parent, bool isNested) _parent = parent; _isNested = isNested; _isRunspacePushed = parent.IsRunspacePushed; - parent.RunspacePopped += new EventHandler(HandleRunspacePopped); - parent.RunspacePushed += new EventHandler(HandleRunspacePushed); + parent.RunspacePopped += HandleRunspacePopped; + parent.RunspacePushed += HandleRunspacePushed; _exec = new Executor(parent, isNested, false); _promptExec = new Executor(parent, isNested, true); } diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/Executor.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/Executor.cs index bdba911e298..03e5b8d8587 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/Executor.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/Executor.cs @@ -131,7 +131,7 @@ private class PipelineFinishedWaitHandle { internal PipelineFinishedWaitHandle(Pipeline p) { - p.StateChanged += new EventHandler(PipelineStateChangedHandler); + p.StateChanged += PipelineStateChangedHandler; } internal void Wait() @@ -205,8 +205,8 @@ internal void ExecuteCommandAsyncHelper(Pipeline tempPipeline, out Exception exc tempPipeline.Commands.Add(outDefault); } - tempPipeline.Output.DataReady += new EventHandler(OutputObjectStreamHandler); - tempPipeline.Error.DataReady += new EventHandler(ErrorObjectStreamHandler); + tempPipeline.Output.DataReady += OutputObjectStreamHandler; + tempPipeline.Error.DataReady += ErrorObjectStreamHandler; PipelineFinishedWaitHandle pipelineWaiter = new PipelineFinishedWaitHandle(tempPipeline); // close the input pipeline so the command will do something diff --git a/src/System.Management.Automation/engine/NativeCommandProcessor.cs b/src/System.Management.Automation/engine/NativeCommandProcessor.cs index 9c1a92fcda2..3069571e22e 100644 --- a/src/System.Management.Automation/engine/NativeCommandProcessor.cs +++ b/src/System.Management.Automation/engine/NativeCommandProcessor.cs @@ -1487,7 +1487,7 @@ public ProcessOutputHandler(Process process, BlockingCollection(HandleJobStateChanged); + _job.StateChanged += HandleJobStateChanged; } /// @@ -1392,7 +1392,7 @@ internal override void StopOperation() /// private void RaiseOperationCompleteEvent() { - _job.StateChanged -= new EventHandler(HandleJobStateChanged); + _job.StateChanged -= HandleJobStateChanged; OperationStateEventArgs operationStateArgs = new OperationStateEventArgs(); operationStateArgs.OperationState = OperationState.StartComplete; @@ -1417,7 +1417,7 @@ internal sealed class CloseOrDisconnectRunspaceOperationHelper : IThrottleOperat internal CloseOrDisconnectRunspaceOperationHelper(RemoteRunspace remoteRunspace) { _remoteRunspace = remoteRunspace; - _remoteRunspace.StateChanged += new EventHandler(HandleRunspaceStateChanged); + _remoteRunspace.StateChanged += HandleRunspaceStateChanged; } /// @@ -1494,7 +1494,7 @@ internal override void StopOperation() /// private void RaiseOperationCompleteEvent() { - _remoteRunspace.StateChanged -= new EventHandler(HandleRunspaceStateChanged); + _remoteRunspace.StateChanged -= HandleRunspaceStateChanged; OperationStateEventArgs operationStateEventArgs = new OperationStateEventArgs(); diff --git a/src/System.Management.Automation/engine/hostifaces/RunspacePool.cs b/src/System.Management.Automation/engine/hostifaces/RunspacePool.cs index ae97cd8e334..3c88f8b9ff7 100644 --- a/src/System.Management.Automation/engine/hostifaces/RunspacePool.cs +++ b/src/System.Management.Automation/engine/hostifaces/RunspacePool.cs @@ -748,8 +748,7 @@ public event EventHandler StateChanged // call any event handlers on this object, replacing the // internalPool sender with 'this' since receivers // are expecting a RunspacePool. - _internalPool.StateChanged += - new EventHandler(OnStateChanged); + _internalPool.StateChanged += OnStateChanged; } } } @@ -761,8 +760,7 @@ public event EventHandler StateChanged InternalStateChanged -= value; if (InternalStateChanged == null) { - _internalPool.StateChanged -= - new EventHandler(OnStateChanged); + _internalPool.StateChanged -= OnStateChanged; } } } diff --git a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs index df15ce6313e..34a5ad8f03e 100644 --- a/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs +++ b/src/System.Management.Automation/engine/hostifaces/pipelinebase.cs @@ -921,7 +921,7 @@ private set { Dbg.Assert(value != null, "ErrorStream cannot be null"); _errorStream = value; - _errorStream.DataReady += new EventHandler(OnErrorStreamDataReady); + _errorStream.DataReady += OnErrorStreamDataReady; } } @@ -933,7 +933,7 @@ private void OnErrorStreamDataReady(object sender, EventArgs e) // unsubscribe from further event notifications as // this notification is suffice to say there is an // error. - _errorStream.DataReady -= new EventHandler(OnErrorStreamDataReady); + _errorStream.DataReady -= OnErrorStreamDataReady; SetHadErrors(true); } } @@ -1052,7 +1052,7 @@ protected override InputStream.Close(); OutputStream.Close(); - _errorStream.DataReady -= new EventHandler(OnErrorStreamDataReady); + _errorStream.DataReady -= OnErrorStreamDataReady; _errorStream.Close(); _executionEventQueue.Clear(); diff --git a/src/System.Management.Automation/engine/remoting/client/ClientRemotePowerShell.cs b/src/System.Management.Automation/engine/remoting/client/ClientRemotePowerShell.cs index 092eb224e04..4f966f5bdba 100644 --- a/src/System.Management.Automation/engine/remoting/client/ClientRemotePowerShell.cs +++ b/src/System.Management.Automation/engine/remoting/client/ClientRemotePowerShell.cs @@ -251,24 +251,17 @@ internal void Initialize( dataStructureHandler = runspacePool.DataStructureHandler.CreatePowerShellDataStructureHandler(this); // register for events from the data structure handler - dataStructureHandler.InvocationStateInfoReceived += - new EventHandler>(HandleInvocationStateInfoReceived); - dataStructureHandler.OutputReceived += new EventHandler>(HandleOutputReceived); - dataStructureHandler.ErrorReceived += new EventHandler>(HandleErrorReceived); - dataStructureHandler.InformationalMessageReceived += - new EventHandler>(HandleInformationalMessageReceived); - dataStructureHandler.HostCallReceived += - new EventHandler>(HandleHostCallReceived); - dataStructureHandler.ClosedNotificationFromRunspacePool += - new EventHandler>(HandleCloseNotificationFromRunspacePool); - dataStructureHandler.BrokenNotificationFromRunspacePool += - new EventHandler>(HandleBrokenNotificationFromRunspacePool); - dataStructureHandler.ConnectCompleted += new EventHandler>(HandleConnectCompleted); - dataStructureHandler.ReconnectCompleted += new EventHandler>(HandleConnectCompleted); - dataStructureHandler.RobustConnectionNotification += - new EventHandler(HandleRobustConnectionNotification); - dataStructureHandler.CloseCompleted += - new EventHandler(HandleCloseCompleted); + dataStructureHandler.InvocationStateInfoReceived += HandleInvocationStateInfoReceived; + dataStructureHandler.OutputReceived += HandleOutputReceived; + dataStructureHandler.ErrorReceived += HandleErrorReceived; + dataStructureHandler.InformationalMessageReceived += HandleInformationalMessageReceived; + dataStructureHandler.HostCallReceived += HandleHostCallReceived; + dataStructureHandler.ClosedNotificationFromRunspacePool += HandleCloseNotificationFromRunspacePool; + dataStructureHandler.BrokenNotificationFromRunspacePool += HandleBrokenNotificationFromRunspacePool; + dataStructureHandler.ConnectCompleted += HandleConnectCompleted; + dataStructureHandler.ReconnectCompleted += HandleConnectCompleted; + dataStructureHandler.RobustConnectionNotification += HandleRobustConnectionNotification; + dataStructureHandler.CloseCompleted += HandleCloseCompleted; } /// diff --git a/src/System.Management.Automation/engine/remoting/client/Job.cs b/src/System.Management.Automation/engine/remoting/client/Job.cs index 814b547b3df..1ee63efe705 100644 --- a/src/System.Management.Automation/engine/remoting/client/Job.cs +++ b/src/System.Management.Automation/engine/remoting/client/Job.cs @@ -1788,8 +1788,8 @@ internal PSRemotingJob(string[] computerNames, // Create Child Job and Register for its StateChanged Event PSRemotingChildJob childJob = new PSRemotingChildJob(remoteCommand, helper, _throttleManager); - childJob.StateChanged += new EventHandler(HandleChildJobStateChanged); - childJob.JobUnblocked += new EventHandler(HandleJobUnblocked); + childJob.StateChanged += HandleChildJobStateChanged; + childJob.JobUnblocked += HandleJobUnblocked; // Add this job to list of childjobs ChildJobs.Add(childJob); @@ -1823,8 +1823,8 @@ internal PSRemotingJob(PSSession[] remoteRunspaceInfos, // Create Child Job object and Register for its state changed event PSRemotingChildJob job = new PSRemotingChildJob(remoteCommand, helper, _throttleManager); - job.StateChanged += new EventHandler(HandleChildJobStateChanged); - job.JobUnblocked += new EventHandler(HandleJobUnblocked); + job.StateChanged += HandleChildJobStateChanged; + job.JobUnblocked += HandleJobUnblocked; // Add the child job to list of child jobs ChildJobs.Add(job); @@ -1853,8 +1853,8 @@ internal PSRemotingJob(List helpers, foreach (ExecutionCmdletHelper helper in helpers) { PSRemotingChildJob job = new PSRemotingChildJob(helper, _throttleManager, aggregateResults); - job.StateChanged += new EventHandler(HandleChildJobStateChanged); - job.JobUnblocked += new EventHandler(HandleJobUnblocked); + job.StateChanged += HandleChildJobStateChanged; + job.JobUnblocked += HandleJobUnblocked; ChildJobs.Add(job); } @@ -2685,7 +2685,7 @@ internal class DisconnectedJobOperation : ExecutionCmdletHelper internal DisconnectedJobOperation(Pipeline pipeline) { this.pipeline = pipeline; - this.pipeline.StateChanged += new EventHandler(HandlePipelineStateChanged); + this.pipeline.StateChanged += HandlePipelineStateChanged; } internal override void StartOperation() @@ -2814,15 +2814,15 @@ internal PSRemotingChildJob(ExecutionCmdletHelper helper, ThrottleManager thrott } else { - _remotePipeline.StateChanged += new EventHandler(HandlePipelineStateChanged); - _remotePipeline.Output.DataReady += new EventHandler(HandleOutputReady); - _remotePipeline.Error.DataReady += new EventHandler(HandleErrorReady); + _remotePipeline.StateChanged += HandlePipelineStateChanged; + _remotePipeline.Output.DataReady += HandleOutputReady; + _remotePipeline.Error.DataReady += HandleErrorReady; } Runspace.AvailabilityChanged += HandleRunspaceAvailabilityChanged; IThrottleOperation operation = helper as IThrottleOperation; - operation.OperationComplete += new EventHandler(HandleOperationComplete); + operation.OperationComplete += HandleOperationComplete; SetJobState(JobState.Disconnected, null); } @@ -3494,7 +3494,7 @@ protected virtual void DoCleanupOnFinished() StopAggregateResultsFromHelper(Helper); Runspace.AvailabilityChanged -= HandleRunspaceAvailabilityChanged; IThrottleOperation operation = Helper as IThrottleOperation; - operation.OperationComplete -= new EventHandler(HandleOperationComplete); + operation.OperationComplete -= HandleOperationComplete; UnregisterThrottleComplete(_throttleManager); _throttleManager = null; } @@ -3509,31 +3509,26 @@ protected void AggregateResultsFromHelper(ExecutionCmdletHelper helper) { // Get the pipeline associated with this helper and register for appropriate events Pipeline pipeline = helper.Pipeline; - pipeline.Output.DataReady += new EventHandler(HandleOutputReady); - pipeline.Error.DataReady += new EventHandler(HandleErrorReady); - pipeline.StateChanged += new EventHandler(HandlePipelineStateChanged); + pipeline.Output.DataReady += HandleOutputReady; + pipeline.Error.DataReady += HandleErrorReady; + pipeline.StateChanged += HandlePipelineStateChanged; // Register handler for method executor object stream. Dbg.Assert(pipeline is RemotePipeline, "pipeline is RemotePipeline"); RemotePipeline remotePipeline = pipeline as RemotePipeline; - remotePipeline.MethodExecutorStream.DataReady += new EventHandler(HandleHostCalls); - remotePipeline.PowerShell.Streams.Progress.DataAdded += - new EventHandler(HandleProgressAdded); - remotePipeline.PowerShell.Streams.Warning.DataAdded += - new EventHandler(HandleWarningAdded); - remotePipeline.PowerShell.Streams.Verbose.DataAdded += - new EventHandler(HandleVerboseAdded); - remotePipeline.PowerShell.Streams.Debug.DataAdded += - new EventHandler(HandleDebugAdded); - remotePipeline.PowerShell.Streams.Information.DataAdded += - new EventHandler(HandleInformationAdded); + remotePipeline.MethodExecutorStream.DataReady += HandleHostCalls; + remotePipeline.PowerShell.Streams.Progress.DataAdded += HandleProgressAdded; + remotePipeline.PowerShell.Streams.Warning.DataAdded += HandleWarningAdded; + remotePipeline.PowerShell.Streams.Verbose.DataAdded += HandleVerboseAdded; + remotePipeline.PowerShell.Streams.Debug.DataAdded += HandleDebugAdded; + remotePipeline.PowerShell.Streams.Information.DataAdded += HandleInformationAdded; // Enable method executor stream so that host methods are queued up // on it instead of being executed asynchronously when they arrive. remotePipeline.IsMethodExecutorStreamEnabled = true; IThrottleOperation operation = helper as IThrottleOperation; - operation.OperationComplete += new EventHandler(HandleOperationComplete); + operation.OperationComplete += HandleOperationComplete; } /// @@ -3686,19 +3681,14 @@ protected void RemoveAggreateCallbacksFromHelper(ExecutionCmdletHelper helper) // Remove old data aggregation and host calls. Dbg.Assert(pipeline is RemotePipeline, "pipeline is RemotePipeline"); RemotePipeline remotePipeline = pipeline as RemotePipeline; - remotePipeline.MethodExecutorStream.DataReady -= new EventHandler(HandleHostCalls); + remotePipeline.MethodExecutorStream.DataReady -= HandleHostCalls; if (remotePipeline.PowerShell != null) { - remotePipeline.PowerShell.Streams.Progress.DataAdded -= - new EventHandler(HandleProgressAdded); - remotePipeline.PowerShell.Streams.Warning.DataAdded -= - new EventHandler(HandleWarningAdded); - remotePipeline.PowerShell.Streams.Verbose.DataAdded -= - new EventHandler(HandleVerboseAdded); - remotePipeline.PowerShell.Streams.Debug.DataAdded -= - new EventHandler(HandleDebugAdded); - remotePipeline.PowerShell.Streams.Information.DataAdded -= - new EventHandler(HandleInformationAdded); + remotePipeline.PowerShell.Streams.Progress.DataAdded -= HandleProgressAdded; + remotePipeline.PowerShell.Streams.Warning.DataAdded -= HandleWarningAdded; + remotePipeline.PowerShell.Streams.Verbose.DataAdded -= HandleVerboseAdded; + remotePipeline.PowerShell.Streams.Debug.DataAdded -= HandleDebugAdded; + remotePipeline.PowerShell.Streams.Information.DataAdded -= HandleInformationAdded; remotePipeline.IsMethodExecutorStreamEnabled = false; } } @@ -3710,7 +3700,7 @@ protected void RemoveAggreateCallbacksFromHelper(ExecutionCmdletHelper helper) /// protected void RegisterThrottleComplete(ThrottleManager throttleManager) { - throttleManager.ThrottleComplete += new EventHandler(HandleThrottleComplete); + throttleManager.ThrottleComplete += HandleThrottleComplete; } /// @@ -3720,7 +3710,7 @@ protected void RegisterThrottleComplete(ThrottleManager throttleManager) /// protected void UnregisterThrottleComplete(ThrottleManager throttleManager) { - throttleManager.ThrottleComplete -= new EventHandler(HandleThrottleComplete); + throttleManager.ThrottleComplete -= HandleThrottleComplete; } /// diff --git a/src/System.Management.Automation/engine/remoting/client/Job2.cs b/src/System.Management.Automation/engine/remoting/client/Job2.cs index ed9e133059e..32923806cce 100644 --- a/src/System.Management.Automation/engine/remoting/client/Job2.cs +++ b/src/System.Management.Automation/engine/remoting/client/Job2.cs @@ -720,7 +720,7 @@ public void AddChildJob(Job2 childJob) // Store job's state and subscribe to State Changed event. Locking here will // ensure that the jobstateinfo we get is the state before any state changed events are handled by ContainerParentJob. childJobStateInfo = childJob.JobStateInfo; - childJob.StateChanged += new EventHandler(HandleChildJobStateChanged); + childJob.StateChanged += HandleChildJobStateChanged; } ChildJobs.Add(childJob); diff --git a/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs b/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs index 8c35c5f948f..7c2aceec7d4 100644 --- a/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs +++ b/src/System.Management.Automation/engine/remoting/client/RemoteRunspacePoolInternal.cs @@ -172,32 +172,19 @@ private void CreateDSHandler(TypeTable typeTable) DataStructureHandler = new ClientRunspacePoolDataStructureHandler(this, typeTable); // register for events from the data structure handler - DataStructureHandler.RemoteHostCallReceived += - new EventHandler>(HandleRemoteHostCalls); - DataStructureHandler.StateInfoReceived += - new EventHandler>(HandleStateInfoReceived); - DataStructureHandler.RSPoolInitInfoReceived += - new EventHandler>(HandleInitInfoReceived); - DataStructureHandler.ApplicationPrivateDataReceived += - new EventHandler>(HandleApplicationPrivateDataReceived); - DataStructureHandler.SessionClosing += - new EventHandler>(HandleSessionClosing); - DataStructureHandler.SessionClosed += - new EventHandler>(HandleSessionClosed); - DataStructureHandler.SetMaxMinRunspacesResponseReceived += - new EventHandler>(HandleResponseReceived); - DataStructureHandler.URIRedirectionReported += - new EventHandler>(HandleURIDirectionReported); - DataStructureHandler.PSEventArgsReceived += - new EventHandler>(HandlePSEventArgsReceived); - DataStructureHandler.SessionDisconnected += - new EventHandler>(HandleSessionDisconnected); - DataStructureHandler.SessionReconnected += - new EventHandler>(HandleSessionReconnected); - DataStructureHandler.SessionRCDisconnecting += - new EventHandler>(HandleSessionRCDisconnecting); - DataStructureHandler.SessionCreateCompleted += - new EventHandler(HandleSessionCreateCompleted); + DataStructureHandler.RemoteHostCallReceived += HandleRemoteHostCalls; + DataStructureHandler.StateInfoReceived += HandleStateInfoReceived; + DataStructureHandler.RSPoolInitInfoReceived += HandleInitInfoReceived; + DataStructureHandler.ApplicationPrivateDataReceived += HandleApplicationPrivateDataReceived; + DataStructureHandler.SessionClosing += HandleSessionClosing; + DataStructureHandler.SessionClosed += HandleSessionClosed; + DataStructureHandler.SetMaxMinRunspacesResponseReceived += HandleResponseReceived; + DataStructureHandler.URIRedirectionReported += HandleURIDirectionReported; + DataStructureHandler.PSEventArgsReceived += HandlePSEventArgsReceived; + DataStructureHandler.SessionDisconnected += HandleSessionDisconnected; + DataStructureHandler.SessionReconnected += HandleSessionReconnected; + DataStructureHandler.SessionRCDisconnecting += HandleSessionRCDisconnecting; + DataStructureHandler.SessionCreateCompleted += HandleSessionCreateCompleted; } #endregion Constructors diff --git a/src/System.Management.Automation/engine/remoting/client/RemotingProtocol2.cs b/src/System.Management.Automation/engine/remoting/client/RemotingProtocol2.cs index 99a21bd90eb..11ce70dd186 100644 --- a/src/System.Management.Automation/engine/remoting/client/RemotingProtocol2.cs +++ b/src/System.Management.Automation/engine/remoting/client/RemotingProtocol2.cs @@ -43,16 +43,11 @@ internal ClientRunspacePoolDataStructureHandler(RemoteRunspacePoolInternal clien // TODO: Assign remote session name.. should be passed from clientRunspacePool _transportManager = RemoteSession.SessionDataStructureHandler.TransportManager; _transportManager.TypeTable = typeTable; - RemoteSession.StateChanged += - new EventHandler( - HandleClientRemoteSessionStateChanged); + RemoteSession.StateChanged += HandleClientRemoteSessionStateChanged; _reconnecting = false; - _transportManager.RobustConnectionNotification += - new EventHandler(HandleRobustConnectionNotification); - - _transportManager.CreateCompleted += - new EventHandler(HandleSessionCreateCompleted); + _transportManager.RobustConnectionNotification += HandleRobustConnectionNotification; + _transportManager.CreateCompleted += HandleSessionCreateCompleted; } #endregion Constructors @@ -234,8 +229,7 @@ internal void CreatePowerShellOnServerAndInvoke(ClientRemotePowerShell shell) _associatedPowerShellDSHandlers.Add(shell.InstanceId, shell.DataStructureHandler); } - shell.DataStructureHandler.RemoveAssociation += - new EventHandler(HandleRemoveAssociation); + shell.DataStructureHandler.RemoveAssociation += HandleRemoveAssociation; // Find out if this is an invoke and disconnect operation and if so whether the endpoint // supports disconnect. Throw exception if disconnect is not supported. @@ -266,7 +260,7 @@ internal void AddRemotePowerShellDSHandler(Guid psShellInstanceId, ClientPowerSh _associatedPowerShellDSHandlers[psShellInstanceId] = psDSHandler; } - psDSHandler.RemoveAssociation += new EventHandler(HandleRemoveAssociation); + psDSHandler.RemoveAssociation += HandleRemoveAssociation; } /// @@ -1193,7 +1187,7 @@ internal void SendInput(ObjectStreamBase inputstream) // registered lock (_inputSyncObject) { - inputstream.DataReady += new EventHandler(HandleInputDataReady); + inputstream.DataReady += HandleInputDataReady; WriteInput(inputstream); } } @@ -1498,7 +1492,7 @@ internal ClientPowerShellDataStructureHandler(BaseClientCommandTransportManager TransportManager = transportManager; this.clientRunspacePoolId = clientRunspacePoolId; this.clientPowerShellId = clientPowerShellId; - transportManager.SignalCompleted += new EventHandler(OnSignalCompleted); + transportManager.SignalCompleted += OnSignalCompleted; } #endregion Constructors diff --git a/src/System.Management.Automation/engine/remoting/client/RunspaceRef.cs b/src/System.Management.Automation/engine/remoting/client/RunspaceRef.cs index acf5d8cee8c..270e24eb1bd 100644 --- a/src/System.Management.Automation/engine/remoting/client/RunspaceRef.cs +++ b/src/System.Management.Automation/engine/remoting/client/RunspaceRef.cs @@ -222,8 +222,7 @@ internal Pipeline CreatePipeline(string line, bool addToHistory, bool useNestedP PowerShell shell = remotePipeline.PowerShell; if (shell.RemotePowerShell != null) { - shell.RemotePowerShell.RCConnectionNotification += - new EventHandler(HandleRCConnectionNotification); + shell.RemotePowerShell.RCConnectionNotification += HandleRCConnectionNotification; } // Add callback to write robust connection errors from stream. @@ -314,12 +313,11 @@ internal void Override(RemoteRunspace remoteRunspace, object syncObject, out boo powerShell.AddParameter("Name", new string[] { "Out-Default", "Exit-PSSession" }); powerShell.Runspace = _runspaceRef.Value; - bool isReleaseCandidateBackcompatibilityMode = - _runspaceRef.Value.GetRemoteProtocolVersion() == RemotingConstants.ProtocolVersionWin7RC; + bool isReleaseCandidateBackcompatibilityMode = _runspaceRef.Value.GetRemoteProtocolVersion() == RemotingConstants.ProtocolVersionWin7RC; powerShell.IsGetCommandMetadataSpecialPipeline = !isReleaseCandidateBackcompatibilityMode; int expectedNumberOfResults = isReleaseCandidateBackcompatibilityMode ? 2 : 3; - powerShell.RemotePowerShell.HostCallReceived += new EventHandler>(HandleHostCall); + powerShell.RemotePowerShell.HostCallReceived += HandleHostCall; IAsyncResult asyncResult = powerShell.BeginInvoke(); PSDataCollection results = new PSDataCollection(); diff --git a/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs b/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs index eb3ad0d20f8..efb47508bcc 100644 --- a/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs +++ b/src/System.Management.Automation/engine/remoting/client/ThrottlingJob.cs @@ -424,7 +424,7 @@ internal void AddChildJobWithoutBlocking(StartableJob childJob, ChildJobFlags fl childJob.StateChanged += this.childJob_StateChanged; if (_cmdletMode) { - childJob.Results.DataAdded += new EventHandler(childJob_ResultsAdded); + childJob.Results.DataAdded += childJob_ResultsAdded; } this.EnqueueReadyToRunChildJob(childJob); diff --git a/src/System.Management.Automation/engine/remoting/client/clientremotesession.cs b/src/System.Management.Automation/engine/remoting/client/clientremotesession.cs index e3249765446..a2875f819fe 100644 --- a/src/System.Management.Automation/engine/remoting/client/clientremotesession.cs +++ b/src/System.Management.Automation/engine/remoting/client/clientremotesession.cs @@ -221,10 +221,8 @@ internal ClientRemoteSessionImpl(RemoteRunspacePoolInternal rsPool, // Register handlers for various ClientSessiondata structure handler events SessionDataStructureHandler.NegotiationReceived += HandleNegotiationReceived; SessionDataStructureHandler.ConnectionStateChanged += HandleConnectionStateChanged; - SessionDataStructureHandler.EncryptedSessionKeyReceived += - new EventHandler>(HandleEncryptedSessionKeyReceived); - SessionDataStructureHandler.PublicKeyRequestReceived += - new EventHandler>(HandlePublicKeyRequestReceived); + SessionDataStructureHandler.EncryptedSessionKeyReceived += HandleEncryptedSessionKeyReceived; + SessionDataStructureHandler.PublicKeyRequestReceived += HandlePublicKeyRequestReceived; } #endregion Constructors diff --git a/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs b/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs index a711c7dd8f2..d8e887becfb 100644 --- a/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs +++ b/src/System.Management.Automation/engine/remoting/client/remotepipeline.cs @@ -126,8 +126,7 @@ internal RemotePipeline(RemoteRunspace runspace, string command, bool addToHisto _powershell.SetIsNested(isNested); - _powershell.InvocationStateChanged += - new EventHandler(HandleInvocationStateChanged); + _powershell.InvocationStateChanged += HandleInvocationStateChanged; } /// @@ -153,8 +152,7 @@ internal RemotePipeline(RemoteRunspace runspace) _powershell = new PowerShell(_connectCmdInfo, _inputStream, _outputStream, _errorStream, ((RemoteRunspace)_runspace).RunspacePool); - _powershell.InvocationStateChanged += - new EventHandler(HandleInvocationStateChanged); + _powershell.InvocationStateChanged += HandleInvocationStateChanged; } /// @@ -894,8 +892,7 @@ private void InitPowerShell(bool syncCall, bool invokeAndDisconnect = false) _powershell.InitForRemotePipeline(_commands, _inputStream, _outputStream, _errorStream, settings, RedirectShellErrorOutputPipe); - _powershell.RemotePowerShell.HostCallReceived += - new EventHandler>(HandleHostCallReceived); + _powershell.RemotePowerShell.HostCallReceived += HandleHostCallReceived; } /// @@ -931,8 +928,7 @@ private void InitPowerShellForConnect(bool syncCall) _powershell.InitForRemotePipelineConnect(_inputStream, _outputStream, _errorStream, settings, RedirectShellErrorOutputPipe); - _powershell.RemotePowerShell.HostCallReceived += - new EventHandler>(HandleHostCallReceived); + _powershell.RemotePowerShell.HostCallReceived += HandleHostCallReceived; } } diff --git a/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs b/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs index 751969d6f82..208f4804ee1 100644 --- a/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs +++ b/src/System.Management.Automation/engine/remoting/client/remoterunspace.cs @@ -203,17 +203,11 @@ private void SetEventHandlers() _eventManager = new PSRemoteEventManager(_connectionInfo.ComputerName, this.InstanceId); - RunspacePool.StateChanged += - new EventHandler(HandleRunspacePoolStateChanged); - RunspacePool.RemoteRunspacePoolInternal.HostCallReceived += - new EventHandler>(HandleHostCallReceived); - RunspacePool.RemoteRunspacePoolInternal.URIRedirectionReported += - new EventHandler>(HandleURIDirectionReported); - RunspacePool.ForwardEvent += - new EventHandler(HandleRunspacePoolForwardEvent); - - RunspacePool.RemoteRunspacePoolInternal.SessionCreateCompleted += - new EventHandler(HandleSessionCreateCompleted); + RunspacePool.StateChanged += HandleRunspacePoolStateChanged; + RunspacePool.RemoteRunspacePoolInternal.HostCallReceived += HandleHostCallReceived; + RunspacePool.RemoteRunspacePoolInternal.URIRedirectionReported += HandleURIDirectionReported; + RunspacePool.ForwardEvent += HandleRunspacePoolForwardEvent; + RunspacePool.RemoteRunspacePoolInternal.SessionCreateCompleted += HandleSessionCreateCompleted; } #endregion Constructors @@ -656,17 +650,11 @@ protected override void Dispose(bool disposing) try { - RunspacePool.StateChanged -= - new EventHandler(HandleRunspacePoolStateChanged); - RunspacePool.RemoteRunspacePoolInternal.HostCallReceived -= - new EventHandler>(HandleHostCallReceived); - RunspacePool.RemoteRunspacePoolInternal.URIRedirectionReported -= - new EventHandler>(HandleURIDirectionReported); - RunspacePool.ForwardEvent -= - new EventHandler(HandleRunspacePoolForwardEvent); - - RunspacePool.RemoteRunspacePoolInternal.SessionCreateCompleted -= - new EventHandler(HandleSessionCreateCompleted); + RunspacePool.StateChanged -= HandleRunspacePoolStateChanged; + RunspacePool.RemoteRunspacePoolInternal.HostCallReceived -= HandleHostCallReceived; + RunspacePool.RemoteRunspacePoolInternal.URIRedirectionReported -= HandleURIDirectionReported; + RunspacePool.ForwardEvent -= HandleRunspacePoolForwardEvent; + RunspacePool.RemoteRunspacePoolInternal.SessionCreateCompleted -= HandleSessionCreateCompleted; _eventManager = null; diff --git a/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs b/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs index bfabb23b7b7..8615bf3398a 100644 --- a/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs +++ b/src/System.Management.Automation/engine/remoting/client/remotingprotocolimplementation.cs @@ -91,7 +91,7 @@ internal ClientRemoteSessionDSHandlerImpl(ClientRemoteSession session, _transportManager.DisconnectCompleted += HandleDisconnectComplete; _transportManager.ReconnectCompleted += HandleReconnectComplete; - _transportManager.RobustConnectionNotification += new EventHandler(HandleRobustConnectionNotification); + _transportManager.RobustConnectionNotification += HandleRobustConnectionNotification; WSManConnectionInfo wsmanConnectionInfo = _connectionInfo as WSManConnectionInfo; if (wsmanConnectionInfo != null) diff --git a/src/System.Management.Automation/engine/remoting/commands/ConnectPSSession.cs b/src/System.Management.Automation/engine/remoting/commands/ConnectPSSession.cs index 452a6b10b75..5f66afdfac1 100644 --- a/src/System.Management.Automation/engine/remoting/commands/ConnectPSSession.cs +++ b/src/System.Management.Automation/engine/remoting/commands/ConnectPSSession.cs @@ -354,7 +354,7 @@ protected override void BeginProcessing() base.BeginProcessing(); _throttleManager.ThrottleLimit = ThrottleLimit; - _throttleManager.ThrottleComplete += new EventHandler(HandleThrottleConnectComplete); + _throttleManager.ThrottleComplete += HandleThrottleConnectComplete; } /// @@ -1072,7 +1072,7 @@ private void Dispose(bool disposing) _operationsComplete.WaitOne(); _operationsComplete.Dispose(); - _throttleManager.ThrottleComplete -= new EventHandler(HandleThrottleConnectComplete); + _throttleManager.ThrottleComplete -= HandleThrottleConnectComplete; _retryThrottleManager.Dispose(); _stream.Dispose(); diff --git a/src/System.Management.Automation/engine/remoting/commands/DisconnectPSSession.cs b/src/System.Management.Automation/engine/remoting/commands/DisconnectPSSession.cs index dd4f153ca1d..0b9cfeb2d6e 100644 --- a/src/System.Management.Automation/engine/remoting/commands/DisconnectPSSession.cs +++ b/src/System.Management.Automation/engine/remoting/commands/DisconnectPSSession.cs @@ -160,7 +160,7 @@ protected override void BeginProcessing() base.BeginProcessing(); _throttleManager.ThrottleLimit = ThrottleLimit; - _throttleManager.ThrottleComplete += new EventHandler(HandleThrottleDisconnectComplete); + _throttleManager.ThrottleComplete += HandleThrottleDisconnectComplete; } /// @@ -546,7 +546,7 @@ private void Dispose(bool disposing) _operationsComplete.WaitOne(); _operationsComplete.Dispose(); - _throttleManager.ThrottleComplete -= new EventHandler(HandleThrottleDisconnectComplete); + _throttleManager.ThrottleComplete -= HandleThrottleDisconnectComplete; _stream.Dispose(); } } diff --git a/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs b/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs index bd7729acbd4..daef292017f 100644 --- a/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs +++ b/src/System.Management.Automation/engine/remoting/commands/InvokeCommandCommand.cs @@ -1359,7 +1359,7 @@ private Debugger GetHostDebugger() private void HandleThrottleComplete(object sender, EventArgs eventArgs) { _operationsComplete.Set(); - _throttleManager.ThrottleComplete -= new EventHandler(HandleThrottleComplete); + _throttleManager.ThrottleComplete -= HandleThrottleComplete; } /// @@ -1389,14 +1389,14 @@ private void CreateAndRunSyncJob() if (!_nojob) { _throttleManager.ThrottleLimit = ThrottleLimit; - _throttleManager.ThrottleComplete += new EventHandler(HandleThrottleComplete); + _throttleManager.ThrottleComplete += HandleThrottleComplete; _operationsComplete.Reset(); Dbg.Assert(_disconnectComplete == null, "disconnectComplete event should only be used once."); _disconnectComplete = new ManualResetEvent(false); _job = new PSInvokeExpressionSyncJob(Operations, _throttleManager); _job.HideComputerName = _hideComputerName; - _job.StateChanged += new EventHandler(HandleJobStateChanged); + _job.StateChanged += HandleJobStateChanged; // Add robust connection retry notification handler. AddConnectionRetryHandler(_job); @@ -1435,7 +1435,7 @@ private void HandleJobStateChanged(object sender, JobStateEventArgs e) state == JobState.Stopped || state == JobState.Failed) { - _job.StateChanged -= new EventHandler(HandleJobStateChanged); + _job.StateChanged -= HandleJobStateChanged; RemoveConnectionRetryHandler(sender as PSInvokeExpressionSyncJob); // Signal that this job has been disconnected, or has ended. @@ -1461,8 +1461,7 @@ private void AddConnectionRetryHandler(PSInvokeExpressionSyncJob job) { if (ps.RemotePowerShell != null) { - ps.RemotePowerShell.RCConnectionNotification += - new EventHandler(RCConnectionNotificationHandler); + ps.RemotePowerShell.RCConnectionNotification += RCConnectionNotificationHandler; } } } @@ -1482,8 +1481,7 @@ private void RemoveConnectionRetryHandler(PSInvokeExpressionSyncJob job) { if (ps.RemotePowerShell != null) { - ps.RemotePowerShell.RCConnectionNotification -= - new EventHandler(RCConnectionNotificationHandler); + ps.RemotePowerShell.RCConnectionNotification -= RCConnectionNotificationHandler; } } } @@ -2056,7 +2054,7 @@ private void Dispose(bool disposing) _job.Dispose(); } - _throttleManager.ThrottleComplete -= new EventHandler(HandleThrottleComplete); + _throttleManager.ThrottleComplete -= HandleThrottleComplete; _throttleManager.Dispose(); _throttleManager = null; } diff --git a/src/System.Management.Automation/engine/remoting/commands/PSRemotingCmdlet.cs b/src/System.Management.Automation/engine/remoting/commands/PSRemotingCmdlet.cs index 0abb3c24837..de046236536 100644 --- a/src/System.Management.Automation/engine/remoting/commands/PSRemotingCmdlet.cs +++ b/src/System.Management.Automation/engine/remoting/commands/PSRemotingCmdlet.cs @@ -3328,7 +3328,7 @@ internal ExecutionCmdletHelperRunspace(Pipeline pipeline) { this.pipeline = pipeline; PipelineRunspace = pipeline.Runspace; - this.pipeline.StateChanged += new EventHandler(HandlePipelineStateChanged); + this.pipeline.StateChanged += HandlePipelineStateChanged; } /// @@ -3436,7 +3436,7 @@ private void RaiseOperationCompleteEvent(EventArgs baseEventArgs) { // Dispose the pipeline object and release data and remoting resources. // Pipeline object remains to provide information on final state and any errors incurred. - pipeline.StateChanged -= new EventHandler(HandlePipelineStateChanged); + pipeline.StateChanged -= HandlePipelineStateChanged; pipeline.Dispose(); } @@ -3496,15 +3496,13 @@ internal ExecutionCmdletHelperComputerName(RemoteRunspace remoteRunspace, Pipeli _invokeAndDisconnect = invokeAndDisconnect; RemoteRunspace = remoteRunspace; - remoteRunspace.StateChanged += - new EventHandler(HandleRunspaceStateChanged); + remoteRunspace.StateChanged += HandleRunspaceStateChanged; Dbg.Assert(pipeline != null, "Pipeline cannot be null or empty"); this.pipeline = pipeline; - pipeline.StateChanged += - new EventHandler(HandlePipelineStateChanged); + pipeline.StateChanged += HandlePipelineStateChanged; } /// @@ -3675,7 +3673,7 @@ private void RaiseOperationCompleteEvent(EventArgs baseEventArgs) { // Dispose the pipeline object and release data and remoting resources. // Pipeline object remains to provide information on final state and any errors incurred. - pipeline.StateChanged -= new EventHandler(HandlePipelineStateChanged); + pipeline.StateChanged -= HandlePipelineStateChanged; pipeline.Dispose(); } diff --git a/src/System.Management.Automation/engine/remoting/commands/newrunspacecommand.cs b/src/System.Management.Automation/engine/remoting/commands/newrunspacecommand.cs index a20b6163495..5645272bbe2 100644 --- a/src/System.Management.Automation/engine/remoting/commands/newrunspacecommand.cs +++ b/src/System.Management.Automation/engine/remoting/commands/newrunspacecommand.cs @@ -181,8 +181,7 @@ protected override void BeginProcessing() base.BeginProcessing(); _operationsComplete.Reset(); _throttleManager.ThrottleLimit = ThrottleLimit; - _throttleManager.ThrottleComplete += - new EventHandler(HandleThrottleComplete); + _throttleManager.ThrottleComplete += HandleThrottleComplete; if (string.IsNullOrEmpty(ConfigurationName)) { @@ -286,8 +285,7 @@ protected override void ProcessRecord() OpenRunspaceOperation operation = new OpenRunspaceOperation(remoteRunspace); // HandleRunspaceStateChanged callback is added before ThrottleManager complete // callback handlers so HandleRunspaceStateChanged will always be called first. - operation.OperationComplete += - new EventHandler(HandleRunspaceStateChanged); + operation.OperationComplete += HandleRunspaceStateChanged; remoteRunspace.URIRedirectionReported += HandleURIDirectionReported; operations.Add(operation); } @@ -1212,7 +1210,7 @@ protected void Dispose(bool disposing) _operationsComplete.WaitOne(); _operationsComplete.Dispose(); - _throttleManager.ThrottleComplete -= new EventHandler(HandleThrottleComplete); + _throttleManager.ThrottleComplete -= HandleThrottleComplete; _throttleManager = null; foreach (RemoteRunspace remoteRunspace in _toDispose) @@ -1321,8 +1319,7 @@ internal OpenRunspaceOperation(RemoteRunspace runspace) _startComplete = true; _stopComplete = true; OperatedRunspace = runspace; - OperatedRunspace.StateChanged += - new EventHandler(HandleRunspaceStateChanged); + OperatedRunspace.StateChanged += HandleRunspaceStateChanged; } /// diff --git a/src/System.Management.Automation/engine/remoting/common/throttlemanager.cs b/src/System.Management.Automation/engine/remoting/common/throttlemanager.cs index 571ec3225d5..9fa2233153f 100644 --- a/src/System.Management.Automation/engine/remoting/common/throttlemanager.cs +++ b/src/System.Management.Automation/engine/remoting/common/throttlemanager.cs @@ -527,8 +527,7 @@ private void StartOneOperationFromQueue() { operation = _operationsQueue[0]; _operationsQueue.RemoveAt(0); - operation.OperationComplete += - new EventHandler(OperationCompleteHandler); + operation.OperationComplete += OperationCompleteHandler; _startOperationQueue.Add(operation); } } diff --git a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs index 4c3961748eb..eb82a8e59a7 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs @@ -1122,7 +1122,7 @@ internal override void CreateAsync() _processInstance.RunspacePool.Dispose(); } - _serverProcess.Exited += new EventHandler(OnExited); + _serverProcess.Exited += OnExited; _processInstance.Start(); StartRedirectionReaderThreads(_serverProcess); diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs index 77c30d4d43e..d5eb990ec57 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPlugin.cs @@ -328,7 +328,7 @@ internal void CreateShell( // Create a shell session wrapper to track and service future interactions. mgdShellSession = new WSManPluginShellSession(requestDetails, serverTransportMgr, remoteShellSession, context); AddToActiveShellSessions(mgdShellSession); - mgdShellSession.SessionClosed += new EventHandler(HandleShellSessionClosed); + mgdShellSession.SessionClosed += HandleShellSessionClosed; if (inboundShellInformation != null) { diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs index 035288443a2..373f8f7e3aa 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginShellSession.cs @@ -59,10 +59,8 @@ protected WSManPluginServerSession( this.creationRequestDetails = creationRequestDetails; this.transportMgr = transportMgr; - transportMgr.PrepareCalled += - new EventHandler(this.HandlePrepareFromTransportManager); - transportMgr.WSManTransportErrorOccured += - new EventHandler(this.HandleTransportError); + transportMgr.PrepareCalled += this.HandlePrepareFromTransportManager; + transportMgr.WSManTransportErrorOccured += this.HandleTransportError; } public void Dispose() @@ -327,7 +325,7 @@ internal void HandlePrepareFromTransportManager(object sender, EventArgs eventAr { ReportContext(); ReportSendOperationComplete(); - transportMgr.PrepareCalled -= new EventHandler(this.HandlePrepareFromTransportManager); + transportMgr.PrepareCalled -= this.HandlePrepareFromTransportManager; } internal void Close(bool isShuttingDown) @@ -350,8 +348,7 @@ internal void Close(bool isShuttingDown) shutDownContext = null; } - transportMgr.WSManTransportErrorOccured -= - new EventHandler(this.HandleTransportError); + transportMgr.WSManTransportErrorOccured -= this.HandleTransportError; // We should not use request details again after so releasing the resource. // Remember not to free this memory as this memory is allocated and owned by WSMan. @@ -523,7 +520,7 @@ internal void CreateCommand( WSManPluginCommandSession mgdCmdSession = new WSManPluginCommandSession(requestDetails, serverCmdTransportMgr, _remoteSession); AddToActiveCmdSessions(mgdCmdSession); - mgdCmdSession.SessionClosed += new EventHandler(this.HandleCommandSessionClosed); + mgdCmdSession.SessionClosed += this.HandleCommandSessionClosed; mgdCmdSession.shutDownContext = new WSManPluginOperationShutdownContext( pluginContext, @@ -640,7 +637,7 @@ private void CloseAndClearCommandSessions( WSManPluginCommandSession cmdSession = cmdSessionEnumerator.Current; // we are not interested in session closed events anymore as we are initiating the close // anyway/ - cmdSession.SessionClosed -= new EventHandler(this.HandleCommandSessionClosed); + cmdSession.SessionClosed -= this.HandleCommandSessionClosed; cmdSession.Close(reasonForClose); } diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs index 2c963a69d16..a5d2cc38735 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManPluginTransportManager.cs @@ -399,7 +399,7 @@ internal WSManPluginCommandTransportManager(WSManPluginServerTransportManager sr internal void Initialize() { - this.PowerShellGuidObserver += new System.EventHandler(OnPowershellGuidReported); + this.PowerShellGuidObserver += OnPowershellGuidReported; this.MigrateDataReadyEventHandlers(_serverTransportMgr); } @@ -407,7 +407,7 @@ private void OnPowershellGuidReported(object src, System.EventArgs args) { _cmdId = (System.Guid)src; _serverTransportMgr.ReportTransportMgrForCmd(_cmdId, this); - this.PowerShellGuidObserver -= new System.EventHandler(this.OnPowershellGuidReported); + this.PowerShellGuidObserver -= this.OnPowershellGuidReported; } } } diff --git a/src/System.Management.Automation/engine/remoting/server/ServerPowerShellDriver.cs b/src/System.Management.Automation/engine/remoting/server/ServerPowerShellDriver.cs index b71da3cb5e7..e52cffd5ce0 100644 --- a/src/System.Management.Automation/engine/remoting/server/ServerPowerShellDriver.cs +++ b/src/System.Management.Automation/engine/remoting/server/ServerPowerShellDriver.cs @@ -130,7 +130,7 @@ internal ServerPowerShellDriver(PowerShell powershell, PowerShell extraPowerShel { InputCollection = new PSDataCollection(); InputCollection.ReleaseOnEnumeration = true; - InputCollection.IdleEvent += new EventHandler(HandleIdleEvent); + InputCollection.IdleEvent += HandleIdleEvent; } RegisterPipelineOutputEventHandlers(_localPowerShellOutput); diff --git a/src/System.Management.Automation/engine/remoting/server/ServerRemotingProtocol2.cs b/src/System.Management.Automation/engine/remoting/server/ServerRemotingProtocol2.cs index 5c63ab47008..72e7db24ae5 100644 --- a/src/System.Management.Automation/engine/remoting/server/ServerRemotingProtocol2.cs +++ b/src/System.Management.Automation/engine/remoting/server/ServerRemotingProtocol2.cs @@ -224,7 +224,7 @@ internal ServerPowerShellDataStructureHandler CreatePowerShellDataStructureHandl _associatedShells.Add(dsHandler.PowerShellId, dsHandler); } - dsHandler.RemoveAssociation += new EventHandler(HandleRemoveAssociation); + dsHandler.RemoveAssociation += HandleRemoveAssociation; return dsHandler; } @@ -465,8 +465,7 @@ internal ServerPowerShellDataStructureHandler(Guid instanceId, Guid runspacePool if (localPowerShell != null) { - localPowerShell.RunspaceAssigned += - new EventHandler>(LocalPowerShell_RunspaceAssigned); + localPowerShell.RunspaceAssigned += LocalPowerShell_RunspaceAssigned; } } diff --git a/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs b/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs index 13223ae1a41..10814c3ea2b 100644 --- a/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs +++ b/src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs @@ -204,30 +204,21 @@ internal ServerRunspacePoolDriver( DataStructureHandler = new ServerRunspacePoolDataStructureHandler(this, transportManager); // handle the StateChanged event of the runspace pool - RunspacePool.StateChanged += - new EventHandler(HandleRunspacePoolStateChanged); + RunspacePool.StateChanged += HandleRunspacePoolStateChanged; // listen for events on the runspace pool - RunspacePool.ForwardEvent += - new EventHandler(HandleRunspacePoolForwardEvent); + RunspacePool.ForwardEvent += HandleRunspacePoolForwardEvent; RunspacePool.RunspaceCreated += HandleRunspaceCreated; // register for all the events from the data structure handler - DataStructureHandler.CreateAndInvokePowerShell += - new EventHandler>>(HandleCreateAndInvokePowerShell); - DataStructureHandler.GetCommandMetadata += - new EventHandler>>(HandleGetCommandMetadata); - DataStructureHandler.HostResponseReceived += - new EventHandler>(HandleHostResponseReceived); - DataStructureHandler.SetMaxRunspacesReceived += - new EventHandler>(HandleSetMaxRunspacesReceived); - DataStructureHandler.SetMinRunspacesReceived += - new EventHandler>(HandleSetMinRunspacesReceived); - DataStructureHandler.GetAvailableRunspacesReceived += - new EventHandler>(HandleGetAvailableRunspacesReceived); - DataStructureHandler.ResetRunspaceState += - new EventHandler>(HandleResetRunspaceState); + DataStructureHandler.CreateAndInvokePowerShell += HandleCreateAndInvokePowerShell; + DataStructureHandler.GetCommandMetadata += HandleGetCommandMetadata; + DataStructureHandler.HostResponseReceived += HandleHostResponseReceived; + DataStructureHandler.SetMaxRunspacesReceived += HandleSetMaxRunspacesReceived; + DataStructureHandler.SetMinRunspacesReceived += HandleSetMinRunspacesReceived; + DataStructureHandler.GetAvailableRunspacesReceived += HandleGetAvailableRunspacesReceived; + DataStructureHandler.ResetRunspaceState += HandleResetRunspaceState; } #endregion Constructors @@ -364,10 +355,8 @@ internal void Close() DisposeRemoteDebugger(); RunspacePool.Close(); - RunspacePool.StateChanged -= - new EventHandler(HandleRunspacePoolStateChanged); - RunspacePool.ForwardEvent -= - new EventHandler(HandleRunspacePoolForwardEvent); + RunspacePool.StateChanged -= HandleRunspacePoolStateChanged; + RunspacePool.ForwardEvent -= HandleRunspacePoolForwardEvent; RunspacePool.Dispose(); RunspacePool = null; diff --git a/src/System.Management.Automation/engine/remoting/server/ServerSteppablePipelineDriver.cs b/src/System.Management.Automation/engine/remoting/server/ServerSteppablePipelineDriver.cs index 9b86ac8c5ca..240395bb567 100644 --- a/src/System.Management.Automation/engine/remoting/server/ServerSteppablePipelineDriver.cs +++ b/src/System.Management.Automation/engine/remoting/server/ServerSteppablePipelineDriver.cs @@ -130,12 +130,11 @@ internal ServerSteppablePipelineDriver(PowerShell powershell, bool noInput, Guid RemoteHost = DataStructureHandler.GetHostAssociatedWithPowerShell(hostInfo, runspacePoolDriver.ServerRemoteHost); // subscribe to various data structure handler events - DataStructureHandler.InputEndReceived += new EventHandler(HandleInputEndReceived); - DataStructureHandler.InputReceived += new EventHandler>(HandleInputReceived); - DataStructureHandler.StopPowerShellReceived += new EventHandler(HandleStopReceived); - DataStructureHandler.HostResponseReceived += - new EventHandler>(HandleHostResponseReceived); - DataStructureHandler.OnSessionConnected += new EventHandler(HandleSessionConnected); + DataStructureHandler.InputEndReceived += HandleInputEndReceived; + DataStructureHandler.InputReceived += HandleInputReceived; + DataStructureHandler.StopPowerShellReceived += HandleStopReceived; + DataStructureHandler.HostResponseReceived += HandleHostResponseReceived; + DataStructureHandler.OnSessionConnected += HandleSessionConnected; if (rsToUse == null) { diff --git a/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs b/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs index a5e018408de..16978ff04e3 100644 --- a/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs +++ b/src/System.Management.Automation/engine/remoting/server/serverremotesession.cs @@ -141,8 +141,7 @@ internal ServerRemoteSession(PSSenderInfo senderInfo, SessionDataStructureHandler.CreateRunspacePoolReceived += HandleCreateRunspacePool; SessionDataStructureHandler.NegotiationReceived += HandleNegotiationReceived; SessionDataStructureHandler.SessionClosing += HandleSessionDSHandlerClosing; - SessionDataStructureHandler.PublicKeyReceived += - new EventHandler>(HandlePublicKeyReceived); + SessionDataStructureHandler.PublicKeyReceived += HandlePublicKeyReceived; transportManager.Closing += HandleResourceClosing; // update the quotas from sessionState..start with default size..and diff --git a/src/System.Management.Automation/help/UpdatableHelpCommandBase.cs b/src/System.Management.Automation/help/UpdatableHelpCommandBase.cs index bbc1d32f6dc..e9f601aba52 100644 --- a/src/System.Management.Automation/help/UpdatableHelpCommandBase.cs +++ b/src/System.Management.Automation/help/UpdatableHelpCommandBase.cs @@ -204,7 +204,7 @@ internal UpdatableHelpCommandBase(UpdatableHelpCommandType commandType) _commandType = commandType; _helpSystem = new UpdatableHelpSystem(this, _useDefaultCredentials); _exceptions = new Dictionary(); - _helpSystem.OnProgressChanged += new EventHandler(HandleProgressChanged); + _helpSystem.OnProgressChanged += HandleProgressChanged; Random rand = new Random(); diff --git a/src/System.Management.Automation/utils/ObjectReader.cs b/src/System.Management.Automation/utils/ObjectReader.cs index 5f9a57eec18..deb056a180e 100644 --- a/src/System.Management.Automation/utils/ObjectReader.cs +++ b/src/System.Management.Automation/utils/ObjectReader.cs @@ -48,7 +48,7 @@ public override event EventHandler DataReady InternalDataReady += value; if (firstRegistrant) { - _stream.DataReady += new EventHandler(this.OnDataReady); + _stream.DataReady += this.OnDataReady; } } } @@ -60,7 +60,7 @@ public override event EventHandler DataReady InternalDataReady -= value; if (InternalDataReady == null) { - _stream.DataReady -= new EventHandler(this.OnDataReady); + _stream.DataReady -= this.OnDataReady; } } }