示例#1
0
        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);

            // Restore global variables
            UrlVariable.ReloadGlobalVariables();
        }
示例#2
0
        public EditVariablesDialog(ApplicationJob job) : base()
        {
            InitializeComponent();
            AcceptButton = bOK;
            CancelButton = bCancel;

            m_Job       = job;
            m_Variables = new ApplicationJob.UrlVariableCollection(job);
            // Get a copy of all variables
            foreach (KeyValuePair <string, UrlVariable> pair in job.Variables)
            {
                UrlVariable clonedVariable = pair.Value.Clone() as UrlVariable;
                m_Variables.Add(pair.Key, clonedVariable);
                clonedVariable.Parent = m_Variables;
            }
        }
示例#3
0
        private void EvaluateRegex(object text)
        {
            try
            {
                try
                {
                    UrlVariable currenVar = this.CurrentVariable;

                    string compareRegex = currenVar.Regex;
                    Regex  regex        = currenVar.CreateRegex();

                    if (regex == null)
                    {
                        return;
                    }

                    Match match = regex.Match(text as string);

                    this.BeginInvoke((MethodInvoker) delegate
                    {
                        this.SetRegexResult(compareRegex, match);
                    });
                }
                catch (UriFormatException ex)
                {
                    this.BeginInvoke((MethodInvoker) delegate
                    {
                        MessageBox.Show(this, "The regular expression cannot be evaluated: " + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    });
                }
                catch (ThreadAbortException)
                {
                    /* Thread aborted, no error */
                }
                finally
                {
                    this.BeginInvoke((MethodInvoker) delegate
                    {
                        this.txtRegularExpression.HintText = string.Empty;
                    });
                }
            }
            catch (InvalidOperationException)
            {
                /* Ignore error if form is closed */
            }
        }
示例#4
0
        private void SaveGlobalVariables()
        {
            UrlVariable.GlobalVariables.Clear();

            foreach (DataRow row in this.globalVarsTable.Rows)
            {
                string varName = row[0] as string;
                // Skip variables without name
                if (string.IsNullOrEmpty(varName))
                {
                    continue;
                }

                UrlVariable newVariable = new UrlVariable(varName, null);
                newVariable.CachedContent            = row[1] as string;
                UrlVariable.GlobalVariables[varName] = newVariable;
            }

            UrlVariable.GlobalVariables.Save();
        }
示例#5
0
        private void SaveGlobalVariables()
        {
            UrlVariable.GlobalVariables.Clear();

            foreach (DataRow row in this.globalVarsTable.Rows)
            {
                string varName = row[0] as string;
                // Skip variables without name
                if (string.IsNullOrEmpty(varName)) continue;

                UrlVariable newVariable = new UrlVariable(varName, null);
                newVariable.CachedContent = row[1] as string;
                UrlVariable.GlobalVariables[varName] = newVariable;
            }

            UrlVariable.GlobalVariables.Save();
        }
示例#6
0
        public static void Log(UrlVariable var, string url, string replacement)
        {
            string prepend = (var.Parent?.Parent == null) ? "" : var.Parent.Parent.Name + ": ";

            Log(prepend + "Replacing {" + var.Name + "} in '" + url + "' with '" + replacement + "'");
        }
示例#7
0
 public static void Log(UrlVariable var, string url, string replacement)
 {
     string prepend = (var.Parent == null || var.Parent.Parent == null) ? "" : var.Parent.Parent.Name + ": ";
     Log(prepend + "Replacing {" + var.Name + "} in '" + url + "' with '" + replacement + "'");
 }