示例#1
0
        private void InPlaceEditPropertyName(SettingsStoreProperty property, IVsWritableSettingsStore settingsStore)
        {
            _control.InPlaceEditListViewItem(property, property.Name, newName =>
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                // Allow renaming to blank to support the (Default) value, but only for strings.
                if (newName.Length == 0 && property.Type != __VsSettingsType.SettingsType_String)
                {
                    ShowErrorMessage("Error renaming property", "Only a string property may have a blank name. Try again with a different name.");
                    return;
                }

                // Check for duplicate names.
                if (settingsStore.PropertyExists(property.CollectionPath, newName))
                {
                    var message = newName.Length == 0 ?
                                  "There is already a (Default) property. Delete it first and try again or use a different name." :
                                  $"There is already a property called '{newName}'. Try again with a different name.";

                    ShowErrorMessage("Error renaming property", message);
                    return;
                }

                // Clone the property then delete the original.
                settingsStore.CopyProperty(property, newName);
                ErrorHandler.ThrowOnFailure(settingsStore.DeleteProperty(property.CollectionPath, property.Name));

                // Update the view model (keeping the selection the same)
                property.Rename(newName);

                Telemetry.Client.TrackEvent("RenameProperty");
            });
        }
示例#2
0
        public bool DeleteProperty(string collection, string propertyName)
        {
            return(NuGetUIThreadHelper.JoinableTaskFactory.Run(async() =>
            {
                await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                return ErrorHandler.Succeeded(_store.DeleteProperty(collection, propertyName));
            }));
        }
        private void InPlaceEditPropertyName(SettingsStoreProperty property, IVsWritableSettingsStore settingsStore)
        {
            _control.InPlaceEditListViewItem(property, property.Name, newName =>
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                // Allow renaming to blank to support the (Default) value, but only for strings.
                if (newName.Length == 0 && property.Type != __VsSettingsType.SettingsType_String)
                {
                    var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
                    ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(0, Guid.Empty, "Error renaming property", "Only a string property may have a blank name. Try again with a different name.", null, 0, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_CRITICAL, 0, out int result));
                    return;
                }

                // Check for duplicate names.
                if (settingsStore.PropertyExists(property.CollectionPath, newName))
                {
                    var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
                    var message = newName.Length == 0 ?
                                  "There is already a (Default) property. Delete it first and try again or use a different name." :
                                  $"There is already a property called '{newName}'. Try again with a different name.";

                    ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(0, Guid.Empty, "Error renaming property", message, null, 0, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGICON.OLEMSGICON_CRITICAL, 0, out int result));
                    return;
                }

                // Clone the property then delete the original.
                settingsStore.CopyProperty(property, newName);
                ErrorHandler.ThrowOnFailure(settingsStore.DeleteProperty(property.CollectionPath, property.Name));

                // Update the view model (keeping the selection the same)
                property.Rename(newName);

                Telemetry.Client.TrackEvent("RenameProperty");
            });
        }
示例#4
0
 public bool DeleteProperty(string collection, string propertyName)
 {
     return(ErrorHandler.Succeeded(_store.DeleteProperty(collection, propertyName)));
 }