public void AddGroup()
        {
            using (var dialog = new AddCustomTagsDialog(Module))
            {
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var newItem      = dialog.Item;
                var service      = (IConfigurationService)GetService(typeof(IConfigurationService));
                var rulesSection = service.GetSection("system.webServer/rewrite/outboundRules");
                ConfigurationElementCollection rulesCollection = rulesSection.GetCollection("customTags");

                if (SelectedItem != newItem)
                {
                    Items.Add(newItem);
                    SelectedItem = newItem;
                }
                else if (newItem.Flag != "Local")
                {
                    rulesCollection.Remove(newItem.Element);
                    newItem.Flag = "Local";
                }

                newItem.AppendTo(rulesCollection);
                service.ServerManager.CommitChanges();
            }
            OnRewriteSettingsSaved();
        }
Esempio n. 2
0
 private void CbTagsSelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbTags.SelectedIndex == cbTags.Items.Count - 1)
     {
         var dialog = new AddCustomTagsDialog(ServiceProvider);
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             cbTags.Items.Insert(0, dialog.Item.Name);
             _feature.Tags.Add(dialog.Item);
             Rule.CustomTags = dialog.Item.Name;
             cbPreCondition.SelectedIndex = 0;
         }
     }
 }