Example #1
0
        public void Revert()
        {
            var dialog = (IManagementUIService)this.GetService(typeof(IManagementUIService));
            var result =
                dialog.ShowMessage(
                    "Reverting to the parent configuration will result in the loss of all settings in the local configuration file for this feature. Are you sure you want to continue?",
                    this.Name, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning,
                    MessageBoxDefaultButton.Button1);

            if (result != DialogResult.Yes)
            {
                return;
            }

            var service = (IConfigurationService)this.GetService(typeof(IConfigurationService));
            var section = service.GetSection("system.webServer/rewrite/allowedServerVariables");
            ConfigurationElementCollection collection = section.GetCollection();

            collection.Clear();
            collection.Delete();
            collection = section.GetCollection();

            this.SelectedItem = null;
            this.Items.Clear();
            foreach (ConfigurationElement ruleElement in collection)
            {
                var node = new AllowedVariableItem(ruleElement, this);
                this.Items.Add(node);
            }

            service.ServerManager.CommitChanges();
            this.OnRewriteSettingsSaved();
        }
 public VariableListViewItem(AllowedVariableItem item, ServerVariablesPage page)
     : base(item.Name)
 {
     this.Item = item;
     _page     = page;
     this.SubItems.Add(new ListViewSubItem(this, item.Flag));
 }
Example #3
0
        public void Load()
        {
            this.Items = new List <AllowedVariableItem>();
            var service = (IConfigurationService)this.GetService(typeof(IConfigurationService));
            var section = service.GetSection("system.webServer/rewrite/allowedServerVariables");
            ConfigurationElementCollection rulesCollection = section.GetCollection();

            foreach (ConfigurationElement ruleElement in rulesCollection)
            {
                var node = new AllowedVariableItem(ruleElement, this);
                this.Items.Add(node);
            }

            this.CanRevert = section.CanRevert();
            this.OnRewriteSettingsSaved();
        }
Example #4
0
        public AddAllowedVariableDialog(IServiceProvider serviceProvider, AllowedVariablesFeature feature)
            : base(serviceProvider)
        {
            InitializeComponent();

            var container = new CompositeDisposable();

            FormClosed += (sender, args) => container.Dispose();

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                if (feature.Items.Any(item => txtName.Text == item.Name))
                {
                    ShowMessage(
                        "The specified server variable already exists.",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1);
                    return;
                }

                Item = new AllowedVariableItem(null, feature)
                {
                    Name = txtName.Text
                };
                DialogResult = DialogResult.OK;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(txtName, "TextChanged")
                .Sample(TimeSpan.FromSeconds(1))
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                btnOK.Enabled = !string.IsNullOrWhiteSpace(txtName.Text);
            }));
        }