/// <summary>
		/// Add a <see cref="ConfigurationUICommand"/> for a particular <see cref="Type"/>.
		/// </summary>
		/// <param name="type">The <see cref="Type"/> the command applies.</param>
		/// <param name="command">The <see cref="ConfigurationUICommand"/> to add.</param>
		public void AddCommand(Type type, ConfigurationUICommand command)
		{
            HierarchyAndType hierarchyAndType = new HierarchyAndType(hierarchyService.SelectedHierarchy, type);
            if (!list.ContainsKey(hierarchyAndType)) list.Add(hierarchyAndType, new List<ConfigurationUICommand>());
            List<ConfigurationUICommand> commands = list[hierarchyAndType];
			commands.Add(command);
		}
		/// <summary>
		/// Remove a <see cref="ConfigurationUICommand"/> for a particular <see cref="Type"/>.
		/// </summary>
		/// <param name="type">The <see cref="Type"/> the command applies.</param>
		/// <param name="command">The <see cref="ConfigurationUICommand"/> to Remove.</param>
		public void RemoveCommand(Type type, ConfigurationUICommand command)
		{
            HierarchyAndType hierarchyAndType = new HierarchyAndType(hierarchyService.SelectedHierarchy, type);
            if (!list.ContainsKey(hierarchyAndType)) return;
            List<ConfigurationUICommand> commands = list[hierarchyAndType];
			commands.Remove(command);
		}
        public override void Register()
        {
            ConfigurationUICommand addEnvironmentCommand = new ConfigurationUICommand(
                ServiceProvider,
                Resources.EnvironmentUICommandText,
                Resources.EnvironmentUICommandLongText,
                CommandState.Enabled, NodeMultiplicity.Allow,
                new AddEnvironmentNodeCommand(ServiceProvider),
                typeof(EnvironmentNode), Shortcut.None, InsertionPoint.New, null);

            AddUICommand(addEnvironmentCommand, typeof(EnvironmentalOverridesNode));

            ConfigurationUICommand openEnvironmentDelta = new ConfigurationUICommand(ServiceProvider,
                Resources.OpenEnvironmentDeltaCommandText,
                Resources.OpenEnvironmentDeltaCommandLongText,
                CommandState.Enabled,
                new OpenEnvironmentDeltaCommand(ServiceProvider),
                Shortcut.None, InsertionPoint.Action, null);

            AddUICommand(openEnvironmentDelta, typeof(EnvironmentalOverridesNode));

            ConfigurationUICommand saveMergedEnvironment = new ConfigurationUICommand(ServiceProvider,
                Resources.SaveMergedEnvironmentCommandText,
                Resources.SaveMergedEnvironmentCommandLongText,
                CommandState.Enabled,
                new SaveMergedEnvironmentCommand(ServiceProvider),
                Shortcut.None, InsertionPoint.Action, null);

            AddUICommand(saveMergedEnvironment, typeof(EnvironmentNode));

            AddDefaultCommands(typeof(EnvironmentNode));

        }
 public ConfigurationMenuItem(ConfigurationNode node, ConfigurationUICommand command)
 {
     Debug.Assert(node != null);
     this.command = command;
     Shortcut = command.Shortcut;
     Text = command.Text;
     this.node = node;
     this.Enabled = (command.GetCommandState(node) == CommandState.Enabled);
 }
 private void AddExportCryptographicKeyCommand(Type nodeType)
 {
     ConfigurationUICommand command = new ConfigurationUICommand(
         ServiceProvider, Resources.ExportKeyCommandText,
         Resources.ExportKeyLongCommandText, CommandState.Enabled, 
         new ExportKeyCommand(ServiceProvider), System.Windows.Forms.Shortcut.None, 
         InsertionPoint.Action, null);
     AddUICommand(command, nodeType);
 }
		private void AddCloseConfigurationApplicationCommand()
		{
			ConfigurationUICommand item = new ConfigurationUICommand(ServiceProvider, 
				Resources.CloseApplicationUICommandText,
				Resources.CloseApplicationUICommandLongText,
				CommandState.Enabled,
				new CloseConfigurationApplicationCommand(ServiceProvider, true),
				Shortcut.None, InsertionPoint.Action, null);
			AddUICommand(item, typeof(ConfigurationApplicationNode));
		}
		private void AddConfigurationSourceCommand()
		{
			ConfigurationUICommand item = new ConfigurationUICommand(ServiceProvider, 
				Resources.ConfigurationSourceUICommandText,
				Resources.ConfigurationSourceUICommandLongText,
				CommandState.Enabled, NodeMultiplicity.Disallow,
				new AddConfigurationSourceSectionNodeCommand(ServiceProvider),
				typeof(ConfigurationSourceSectionNode), Shortcut.None, InsertionPoint.New, null);

			AddUICommand(item, typeof(ConfigurationApplicationNode));
		}
		/// <summary>
		/// Add a <see cref="ConfigurationUICommand"/> object to the <see cref="IUICommandService"/>.
		/// </summary>
		/// <param name="uiCommand">The <see cref="ConfigurationUICommand"/> to add.</param>
		/// <param name="registerType">The <see cref="Type"/> the command is registered.</param>
		protected void AddUICommand(ConfigurationUICommand uiCommand, Type registerType)
		{
			IUICommandService commandService = ServiceHelper.GetUICommandService(serviceProvider);
			commandService.AddCommand(registerType, uiCommand);
		}
		protected void AddChildNodeCommand(string text, string longText, Type childType, Type nodeType, Type registerType, NodeMultiplicity nodeMultiplicity)
		{
			ConfigurationUICommand item = new ConfigurationUICommand(serviceProvider, text,
				longText,
                CommandState.Enabled, nodeMultiplicity,
				new AddChildNodeCommand(serviceProvider, childType),
				nodeType, Shortcut.None, InsertionPoint.New, null);

			AddUICommand(item, registerType);
		}
		protected void AddValidateCommand(Type registerType)
		{
			ConfigurationUICommand item = new ConfigurationUICommand(serviceProvider,
				Resources.ValidateUICommandText,
				Resources.ValidateUICommandLongText,
				CommandState.Enabled,
				new ValidateNodeCommand(serviceProvider, false),
				Shortcut.CtrlShiftV,
				InsertionPoint.Action,
				null);
			AddUICommand(item, registerType);
		}
		protected void AddRemoveCommand(Type registerType)
		{
			ConfigurationUICommand item = new ConfigurationUICommand(serviceProvider,
				Resources.RemoveUICommandText,
				Resources.RemoveUICommandLongText,
				CommandState.Enabled,
				new RemoveNodeCommand(serviceProvider, false),
				Shortcut.None,
				InsertionPoint.Action,
				null);
			AddUICommand(item, registerType);
		}