internal bool OnApply() { try { var packageRestoreConsent = new PackageManagement.PackageRestoreConsent(_settings); packageRestoreConsent.IsGrantedInSettings = packageRestoreConsentCheckBox.Checked; packageRestoreConsent.IsAutomatic = packageRestoreAutomaticCheckBox.Checked; var bindingRedirects = new BindingRedirectBehavior(_settings); bindingRedirects.IsSkipped = skipBindingRedirects.Checked; #if !VS14 // package management format selection var packageManagement = new PackageManagementFormat(_settings); packageManagement.SelectedPackageManagementFormat = defaultPackageManagementFormatItems.SelectedIndex; packageManagement.Enabled = showPackageManagementChooser.Checked; packageManagement.ApplyChanges(); #endif } catch (InvalidOperationException) { MessageHelper.ShowErrorMessage(Resources.ShowError_ConfigInvalidOperation, Resources.ErrorDialogBoxTitle); return(false); } catch (UnauthorizedAccessException) { MessageHelper.ShowErrorMessage(Resources.ShowError_ConfigUnauthorizedAccess, Resources.ErrorDialogBoxTitle); return(false); } return(true); }
internal void OnActivated() { if (!_initialized) { try { var packageRestoreConsent = new PackageManagement.PackageRestoreConsent(_settings); packageRestoreConsentCheckBox.Checked = packageRestoreConsent.IsGrantedInSettings; packageRestoreAutomaticCheckBox.Checked = packageRestoreConsent.IsAutomatic; packageRestoreAutomaticCheckBox.Enabled = packageRestoreConsentCheckBox.Checked; var bindingRedirects = new BindingRedirectBehavior(_settings); skipBindingRedirects.Checked = bindingRedirects.IsSkipped; #if !VS14 // package management format selection var packageManagement = new PackageManagementFormat(_settings); defaultPackageManagementFormatItems.SelectedIndex = packageManagement.SelectedPackageManagementFormat; showPackageManagementChooser.Checked = packageManagement.Enabled; #endif } catch (InvalidOperationException) { MessageHelper.ShowErrorMessage(Resources.ShowError_ConfigInvalidOperation, Resources.ErrorDialogBoxTitle); } catch (UnauthorizedAccessException) { MessageHelper.ShowErrorMessage(Resources.ShowError_ConfigUnauthorizedAccess, Resources.ErrorDialogBoxTitle); } } _initialized = true; }
public bool IsUserConsentGranted() { try { var packageRestoreConsent = new PackageManagement.PackageRestoreConsent(_settings); return(packageRestoreConsent.IsGranted); } catch (Exception exception) { _telemetryProvider.PostFault(exception, typeof(IVsPackageRestorer).FullName); throw; } }
public bool IsUserConsentGranted() { const string eventName = nameof(IVsPackageRestorer) + "." + nameof(IsUserConsentGranted); using var _ = NuGetETW.ExtensibilityEventSource.StartStopEvent(eventName); try { var packageRestoreConsent = new PackageManagement.PackageRestoreConsent(_settings); return(packageRestoreConsent.IsGranted); } catch (Exception exception) { _telemetryProvider.PostFault(exception, typeof(IVsPackageRestorer).FullName); throw; } }
internal bool OnApply() { try { var packageRestoreConsent = new PackageManagement.PackageRestoreConsent(_settings); packageRestoreConsent.IsGrantedInSettings = packageRestoreConsentCheckBox.Checked; packageRestoreConsent.IsAutomatic = packageRestoreAutomaticCheckBox.Checked; var bindingRedirects = new BindingRedirectBehavior(_settings); bindingRedirects.IsSkipped = skipBindingRedirects.Checked; #if !VS14 // package management format selection var packageManagement = new PackageManagementFormat(_settings); packageManagement.SelectedPackageManagementFormat = defaultPackageManagementFormatItems.SelectedIndex; packageManagement.Enabled = showPackageManagementChooser.Checked; packageManagement.ApplyChanges(); #endif } // Thrown during creating or saving NuGet.Config. catch (NuGetConfigurationException ex) { MessageHelper.ShowErrorMessage(ex.Message, Resources.ErrorDialogBoxTitle); return(false); } // Thrown if no nuget.config found. catch (InvalidOperationException ex) { MessageHelper.ShowErrorMessage(ex.Message, Resources.ErrorDialogBoxTitle); return(false); } catch (UnauthorizedAccessException) { MessageHelper.ShowErrorMessage(Resources.ShowError_ConfigUnauthorizedAccess, Resources.ErrorDialogBoxTitle); return(false); } // Unknown exception. catch (Exception ex) { MessageHelper.ShowErrorMessage(Resources.ShowError_ApplySettingFailed, Resources.ErrorDialogBoxTitle); ActivityLog.LogError(NuGetUI.LogEntrySource, ex.ToString()); return(false); } return(true); }
internal void OnActivated() { if (!_initialized) { try { var packageRestoreConsent = new PackageManagement.PackageRestoreConsent(_settings); packageRestoreConsentCheckBox.Checked = packageRestoreConsent.IsGrantedInSettings; packageRestoreAutomaticCheckBox.Checked = packageRestoreConsent.IsAutomatic; packageRestoreAutomaticCheckBox.Enabled = packageRestoreConsentCheckBox.Checked; var bindingRedirects = new BindingRedirectBehavior(_settings); skipBindingRedirects.Checked = bindingRedirects.IsSkipped; #if !VS14 // package management format selection var packageManagement = new PackageManagementFormat(_settings); defaultPackageManagementFormatItems.SelectedIndex = packageManagement.SelectedPackageManagementFormat; showPackageManagementChooser.Checked = packageManagement.Enabled; #endif } // Thrown during creating or saving NuGet.Config. catch (NuGetConfigurationException ex) { MessageHelper.ShowErrorMessage(ex.Message, Resources.ErrorDialogBoxTitle); } // Thrown if no nuget.config found. catch (InvalidOperationException ex) { MessageHelper.ShowErrorMessage(ex.Message, Resources.ErrorDialogBoxTitle); } catch (UnauthorizedAccessException) { MessageHelper.ShowErrorMessage(Resources.ShowError_ConfigUnauthorizedAccess, Resources.ErrorDialogBoxTitle); } // Unknown exception. catch (Exception ex) { MessageHelper.ShowErrorMessage(Resources.ShowError_SettingActivatedFailed, Resources.ErrorDialogBoxTitle); ActivityLog.LogError(NuGetUI.LogEntrySource, ex.ToString()); } } _initialized = true; }
public bool IsUserConsentGranted() { var packageRestoreConsent = new PackageManagement.PackageRestoreConsent(_settings); return(packageRestoreConsent.IsGranted); }