public static ExitAction Create <T>(Action <T> action, T origValue) { var ea = new ExitAction(); ea._action = new ExitAction1 <T>(action, origValue); return(ea); }
public static ExitAction Create(Action action) { var ea = new ExitAction(); ea._action = new ExitAction0(action); return(ea); }
private void selectRules_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { using (var ea = ExitAction.Create(orig => this.Cursor = orig, this.Cursor)) { this.Cursor = Cursors.Wait; if (selectRules.IsVisible && selectRules.RuleConf == null) { initializeSelectRules(); } } }
private void Send_Click(object sender, RoutedEventArgs e) { try { using (ExitAction ea = ExitAction.Create(orig => this.Cursor = orig, this.Cursor)) { this.Cursor = Cursors.Wait; var list = new List <string>(); if (sender == tables) { list.AddRange(GetMainPages(false)); list.AddRange(GetIssues()); list.AddRange(GetTables()); } else if (sender == issue) { list.AddRange(GetMainPages(false)); list.AddRange(GetIssues()); } else if (sender == summary) { list.AddRange(GetMainPages(true)); } var files = from file in list select new KeyValuePair <string, string>(file, File.ReadAllText(file)); files = files.ToArray(); var archive = _reportName + "-report.zip"; Util.Zipper.ZipFiles(files, archive, Encrypt); //Some evil mail clients overrides currentDirectory. Yes we are looking at you Outlook. using (var pathSetter = ExitAction.Create(origPath => Environment.CurrentDirectory = origPath, Environment.CurrentDirectory)) { var mapi = new Util.MAPI(); mapi.AddAttachment(Path.GetFullPath(archive)); mapi.AddRecipientTo("*****@*****.**"); string content = string.Format("Report for database '{0}' attached", _reportName); mapi.SendMailPopup("DBLint Report", content); } } this.Close(); MessageBox.Show("Thank you for sending feedback of our tool.\nWe hope that you found DBLint useful\n", "Thank you!"); } catch (Exception exception) { MessageBox.Show(exception.StackTrace, exception.GetType().Name); throw; } }