internal void Close(CancelEventArgs args) { if (CloseEventHandler != null) { CloseEventHandler.Invoke(this, args); } }
private bool CanContinueDisposing() { var cancelEventArgs = new CancelEventArgs(); _disposingHandlers?.Invoke(this, cancelEventArgs); return(cancelEventArgs.Cancel == false); }
/// <summary> /// Raises a cancel event in the real system. /// </summary> /// <returns>Instance of the ConsoleCancelEventArgs used.</returns> public ConsoleCancelEventArgs RaiseCancelEvent() { var types = new Type[] { typeof(ConsoleSpecialKey) }; var ctor = typeof(ConsoleCancelEventArgs).GetConstructor( BindingFlags.NonPublic | BindingFlags.Instance, null, types, null); var cancelEventArgs = (ConsoleCancelEventArgs)ctor.Invoke(new object[] { ConsoleSpecialKey.ControlBreak }); CancelEventHandler.Invoke(this, cancelEventArgs); return(cancelEventArgs); }
protected override ICopyCallback GetCopyCallback(string destination) { var path = EntryPath; var first = true; var cleanInstall = SelectedOption == CleanOption; var args = new CancelEventArgs(); InstallationStart?.Invoke(null, args); if (args.Cancel) { throw new InformativeException("Can’t install two things at once"); } var installedLogStream = new MemoryStream(); var installedLog = new StreamWriter(installedLogStream); IsBusy = true; return(new CopyCallback(info => { var filename = info.Key; if (path != string.Empty && !FileUtils.IsAffectedBy(filename, path) || !_toInstall.Contains(info.Key) && !_toInstall.Any(x => FileUtils.IsAffectedBy(info.Key, x))) { return null; } var relativePath = FileUtils.GetRelativePath(filename, path); var result = Path.Combine(InstallTo(), relativePath); if (first) { var directory = Path.Combine(InstallTo(), PatchDirectoryName); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } else if (cleanInstall) { PatchVersionInfo.RemovePatch(false).Wait(); } FileUtils.TryToDelete(PatchHelper.GetInstalledLog()); FileUtils.TryToDelete(Path.Combine(PatchHelper.GetRootDirectory(), "config", "data_manifest.ini")); first = false; installedLog.WriteLine(@"# Generated automatically during last patch installation via Content Manager."); installedLog.WriteLine(@"# Do not edit, unless have to for some reason."); installedLog.WriteLine(@"# This particular log was generated during custom ZIP-file installation."); installedLog.WriteLine(@"version: 0"); installedLog.WriteLine(@"build: 0"); } installedLog.WriteLine($@"file: {relativePath}:0:0:0"); return result; }, dispose: () => { installedLog.Dispose(); File.WriteAllBytes(PatchHelper.GetInstalledLog(), installedLogStream.ToArray()); installedLogStream.Dispose(); InstallationEnd?.Invoke(null, EventArgs.Empty); IsBusy = false; PatchHelper.Reload(); if (PatchUpdater.Instance != null) { PatchUpdater.Instance.ForceVersion.Value = true; } })); }
protected void OnConfirmationRequired(CancelEventArgs e) { CancelEventHandler handler = ConfirmationRequired; handler?.Invoke(this, e); }
internal void OnInitSeqGenerator(CancelEventArgs e) { CancelEventHandler handler = InitSeqGenerator; handler?.Invoke(this, e); }
protected void OnSelectedIndexChanging(CancelEventArgs e) { CancelEventHandler changing = SelectedIndexChanging; changing?.Invoke(this, e); }