protected override void OnClosed(EventArgs e) { base.OnClosed(e); // Restore global variables UrlVariable.ReloadGlobalVariables(); }
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; } }
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 */ } }
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(); }
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(); }
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 + "'"); }
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 + "'"); }