public override void RefreshEditor(RefreshContext context, IFigure figure, object model) { var label = figure as INode; var str = model == null? "": model.ToString(); label.Text = str; }
protected override void RefreshEditor(RefreshContext context, SolidLayer figure, Memo model) { if (figure.DragTarget == null) { figure.DragTarget = CreateDragTarget(); } }
protected override void RefreshEditor(RefreshContext context, ImageFigure figure, MemoImage model) { figure.ImageDesc = model.Image; figure.AdjustSize(); UpdateMemoMarkHandles(model); }
private void RefreshObsoleteBranches() { if (IsRefreshing) { _refreshCancellation.Cancel(); IsRefreshing = false; return; } IsRefreshing = true; var curBranch = _gitUiCommands.GitModule.GetSelectedBranch(); var context = new RefreshContext(_gitCommands, IncludeRemoteBranches.Checked, includeUnmergedBranches.Checked, _referenceBranch, _NO_TRANSLATE_Remote.Text, useRegexFilter.Checked ? regexFilter.Text : null, useRegexCaseInsensitive.Checked ? useRegexCaseInsensitive.Checked : false, regexDoesNotMatch.Checked ? regexDoesNotMatch.Checked : false, TimeSpan.FromDays(_days), _refreshCancellation.Token); Task.Factory.StartNew(() => GetObsoleteBranches(context, curBranch).ToList(), CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default) .ContinueWith(task => { if (IsDisposed || context.CancellationToken.IsCancellationRequested) { return; } if (task.IsCompleted) { _branches.Clear(); _branches.AddRange(task.Result); _branches.ResetBindings(); } IsRefreshing = false; }, TaskScheduler.FromCurrentSynchronizationContext()); }
public override void RefreshEditor(RefreshContext context, IFigure figure, object model) { var label = figure as SimpleRect; var listItem = model as ListItem; label.Text = listItem.Text; }
private void RefreshObsoleteBranches() { if (IsRefreshing) { refreshCancellation.Cancel(); IsRefreshing = false; return; } IsRefreshing = true; var context = new RefreshContext(gitCommands, IncludeRemoteBranches.Checked, includeUnmergedBranches.Checked, referenceBranch, remote.Text, useRegexFilter.Checked ? regexFilter.Text : null, TimeSpan.FromDays(days), refreshCancellation.Token); Task.Factory.StartNew(() => GetObsoleteBranches(context).ToList(), CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default) .ContinueWith(task => { if (IsDisposed || context.CancellationToken.IsCancellationRequested) { return; } if (task.IsCompleted) { branches.Clear(); branches.AddRange(task.Result); branches.ResetBindings(); } IsRefreshing = false; }, TaskScheduler.FromCurrentSynchronizationContext()); }
public async Task <bool> Handle(RefreshRequest message, IOutputPort <RefreshResponse> outputPort) { RefreshResponse response = new RefreshResponse { rowInfo = message.rowInfo, dbSetName = message.dbSetName }; try { Metadata.RunTimeMetadata metadata = _service.GetMetadata(); DbSetInfo dbSetInfo = metadata.DbSets.Get(message.dbSetName) ?? throw new InvalidOperationException($"The DbSet {message.dbSetName} was not found in metadata"); message.SetDbSetInfo(dbSetInfo); message.rowInfo.SetDbSetInfo(dbSetInfo); RefreshContext <TService> context = new RefreshContext <TService>(message, response, (TService)_service, _serviceContainer); await _pipeline(context); } catch (Exception ex) { if (ex is System.Reflection.TargetInvocationException) { ex = ex.InnerException; } string err = _onError(ex); response.error = new ErrorInfo(err, ex.GetType().Name); } outputPort.Handle(response); return(true); }
public override void RefreshEditor(RefreshContext context, IFigure figure, object model) { //figure.IsVisible = _UmlPropertyCollection.Count > 0; Host.Parent.RebuildChildren(); Host.Parent.Figure.InvalidateLayout(); //((INode) Host.Parent.Figure).AdjustSize(); }
protected override void RefreshEditor(RefreshContext context, SimpleRect figure, UmlOperation model) { var text = UmlTextUtil.GetOperationText(model); var run = new Run(text); var para = new Paragraph(run) { Padding = Insets.Empty, HorizontalAlignment = Mkamo.Common.DataType.HorizontalAlignment.Left, }; var st = new StyledText.Core.StyledText(para) { Font = MemopadApplication.Instance.Settings.GetDefaultUmlFont(), VerticalAlignment = Mkamo.Common.DataType.VerticalAlignment.Center, }; if (model.IsStatic) { run.Font = new FontDescription(run.Font, run.Font.Style | FontStyle.Underline); } if (model.IsAbstract) { run.Font = new FontDescription(run.Font, run.Font.Style | FontStyle.Italic); } figure.StyledText = st; figure.AdjustSize(); var clsFig = Host.Parent.Parent.Figure as INode; if (clsFig != null) { clsFig.AdjustSize(); } }
protected override void RefreshEditor(RefreshContext context, LineEdge figure, MemoAnchorReference model) { //switch (model.StartCapKind) { // case MemoAnchorReferenceCapKind.Arrow: { // if (!(figure.SourceDecoration is ArrowEdgeDecoration)) { // figure.SourceDecoration = new ArrowEdgeDecoration() { // Foreground = Color.DimGray, // }; // } // break; // } // case MemoAnchorReferenceCapKind.Normal: { // if (figure.SourceDecoration != null) { // figure.SourceDecoration = null; // } // break; // } //} //switch (model.EndCapKind) { // case MemoAnchorReferenceCapKind.Arrow: { // if (!(figure.TargetDecoration is ArrowEdgeDecoration)) { // figure.TargetDecoration = new ArrowEdgeDecoration() { // Foreground = Color.DimGray, // }; // } // break; // } // case MemoAnchorReferenceCapKind.Normal: { // if (figure.TargetDecoration != null) { // figure.TargetDecoration = null; // } // break; // } //} }
private static IEnumerable <string> GetObsoleteBranchNames(RefreshContext context, string curBranch) { RegexOptions options; if (context.RegexIgnoreCase) { options = RegexOptions.Compiled | RegexOptions.IgnoreCase; } else { options = RegexOptions.Compiled; } var regex = string.IsNullOrEmpty(context.RegexFilter) ? null : new Regex(context.RegexFilter, options); bool regexMustMatch = !context.RegexDoesNotMatch; var args = new GitArgumentBuilder("branch") { { context.IncludeRemotes, "-r" }, { !context.IncludeUnmerged, "--merged" }, context.ReferenceBranch }; string[] branches = context.Commands.GitExecutable.GetOutput(args) .Split('\n') .Where(branchName => !string.IsNullOrEmpty(branchName)) .Select(branchName => branchName.Trim('*', ' ', '\n', '\r')) .Where(branchName => branchName != "HEAD" && branchName != curBranch && branchName != context.ReferenceBranch) .ToArray(); return(branches.Where(branchName => (!context.IncludeRemotes || branchName.StartsWith(context.RemoteRepositoryName + "/")) && (regex == null || regex.IsMatch(branchName) == regexMustMatch)).ToArray()); }
private async Task RefreshObsoleteBranchesAsync() { if (IsRefreshing) { _refreshCancellation.Cancel(); IsRefreshing = false; return; } IsRefreshing = true; var curBranch = _gitUiCommands.GitModule.GetSelectedBranch(); var context = new RefreshContext( _gitCommands, IncludeRemoteBranches.Checked, includeUnmergedBranches.Checked, mergedIntoBranch.Text, _NO_TRANSLATE_Remote.Text, useRegexFilter.Checked ? regexFilter.Text : null, useRegexCaseInsensitive.Checked, regexDoesNotMatch.Checked, TimeSpan.FromDays((int)olderThanDays.Value), _refreshCancellation.Token); await TaskScheduler.Default.SwitchTo(alwaysYield : true); IEnumerable <Branch> branches; try { branches = GetObsoleteBranches(context, curBranch); } catch { await this.SwitchToMainThreadAsync(); if (context.CancellationToken.IsCancellationRequested) { return; } throw; } await this.SwitchToMainThreadAsync(); if (context.CancellationToken.IsCancellationRequested) { return; } _branches.Clear(); _branches.AddRange(branches); checkBoxHeaderCell.Checked = _branches.All(b => b.Delete); _branches.ResetBindings(); IsRefreshing = false; }
protected override void RefreshEditor(RefreshContext context, UmlClassFigure figure, UmlClass model) { var stereotypeRun = string.IsNullOrEmpty(model.Stereotype)? null: new Run(UmlTextUtil.GetStereotypeText(model)); var nameRun = new Run(model.Name); var para = default(Paragraph); if (stereotypeRun == null) { para = new Paragraph(nameRun) { Padding = Insets.Empty, HorizontalAlignment = Mkamo.Common.DataType.HorizontalAlignment.Center, }; } else { para = new Paragraph(stereotypeRun) { Padding = Insets.Empty, HorizontalAlignment = Mkamo.Common.DataType.HorizontalAlignment.Center, }; var line = new LineSegment(); line.InsertBefore(nameRun); para.InsertAfter(line); } var st = new StyledText.Core.StyledText(para) { Font = MemopadApplication.Instance.Settings.GetDefaultUmlFont(), VerticalAlignment = Mkamo.Common.DataType.VerticalAlignment.Top, }; if (model.IsAbstract) { nameRun.Font = new FontDescription(nameRun.Font, nameRun.Font.Style | FontStyle.Italic); } figure.StyledText = st; var layout = (ListLayout)figure.Layout; layout.Padding = new Insets( 0, figure.StyledTextBounds.Height + figure.Padding.Height, 0, 0 ); figure.InvalidateLayout(); figure.AdjustSize(); UpdateMemoMarkHandles(model); }
protected override void RefreshEditor(RefreshContext context, MemoFileFigure figure, MemoFile model) { var path = model.Path; if (model.IsEmbedded) { path = Path.Combine(MemopadConsts.EmbeddedFileRoot, path); } var icon = default(Icon); var hIcon = IntPtr.Zero; if (File.Exists(path) || Directory.Exists(path)) { /// アイコン取得 var shinfo = new SHFILEINFO(); var flags = model.IsEmbedded? ShellGetFileInfoFlags.Icon: ShellGetFileInfoFlags.Icon | ShellGetFileInfoFlags.LinkOverlay; var hSuccess = Shell32PI.SHGetFileInfo( path, 0, ref shinfo, (int)Marshal.SizeOf(shinfo), flags ); if (hSuccess != IntPtr.Zero) { hIcon = shinfo.hIcon; icon = Icon.FromHandle(hIcon); } else { icon = SystemIcons.Error; } } else { icon = SystemIcons.Error; } var desc = new IconImageDescription(icon); if (hIcon != IntPtr.Zero) { User32PI.DestroyIcon(hIcon); } figure.Text = string.IsNullOrEmpty(model.Name)? model.Path: model.Name; figure.ImageDesc = desc; figure.AdjustSize(); UpdateMemoMarkHandles(model); }
public void RefreshFigure(RefreshContext context) { if (Figure == null || Controller == null) { return; } using (Figure.DirtManager.BeginDirty()) { Controller.RefreshEditor(context, Figure, Model); Figure.InvalidatePaint(); } }
/// <summary> /// ValidateTokenWithoutLifeCheck /// </summary> /// <param name="context"></param> /// <returns></returns> /// <exception cref="SecurityTokenDecryptionFailedException"></exception> /// <exception cref="SecurityTokenEncryptionKeyNotFoundException"></exception> /// <exception cref="SecurityTokenException"></exception> /// <exception cref="SecurityTokenExpiredException"></exception> /// <exception cref="SecurityTokenInvalidAudienceException"></exception> /// <exception cref="SecurityTokenInvalidLifetimeException"></exception> /// <exception cref="SecurityTokenInvalidSignatureException"></exception> /// <exception cref="SecurityTokenNoExpirationException"></exception> /// <exception cref="SecurityTokenNotYetValidException"></exception> /// <exception cref="SecurityTokenReplayAddFailedException"></exception> /// <exception cref="SecurityTokenReplayDetectedException"></exception> /// <exception cref="HB.Component.Authorization.AuthorizationException"></exception> private ClaimsPrincipal ValidateTokenWithoutLifeCheck(RefreshContext context) { TokenValidationParameters parameters = new TokenValidationParameters { ValidateAudience = false, ValidateLifetime = false, ValidIssuer = _options.OpenIdConnectConfiguration.Issuer, IssuerSigningKeys = _credentialBiz.GetIssuerSigningKeys() }; return(new JwtSecurityTokenHandler().ValidateToken(context.AccessToken, parameters, out _)); }
private string GetRelativePath(RefreshContext context) { string projectRoot = context.SolutionSettings.ProjectRoot; if (!string.IsNullOrEmpty(projectRoot) && SvnItem.IsBelowPath(projectRoot)) { return(SvnItem.SubPath(FullPath, projectRoot).Replace('\\', '/')); } else { return(FullPath); } }
private static IEnumerable <string> GetObsoleteBranchNames(RefreshContext context, string curBranch) { var regex = string.IsNullOrEmpty(context.RegexFilter) ? null : new Regex(context.RegexFilter, RegexOptions.Compiled); return(context.Commands.RunGitCmd("branch" + (context.IncludeRemotes ? " -r" : "") + (context.IncludeUnmerged ? "" : " --merged " + context.ReferenceBranch)) .Split('\n') .Where(branchName => !string.IsNullOrEmpty(branchName)) .Select(branchName => branchName.Trim('*', ' ', '\n', '\r')) .Where(branchName => branchName != "HEAD" && branchName != curBranch && branchName != context.ReferenceBranch && (!context.IncludeRemotes || branchName.StartsWith(context.RemoteRepositoryName + "/")) && (regex == null || regex.IsMatch(branchName)))); }
private static IEnumerable<string> GetObsoleteBranchNames(RefreshContext context) { var regex = string.IsNullOrEmpty(context.RegexFilter) ? null : new Regex(context.RegexFilter, RegexOptions.Compiled); // TODO: skip current branch return context.Commands.RunGitCmd("branch" + (context.IncludeRemotes ? " -r" : "") + (context.IncludeUnmerged ? "" : " --merged " + context.ReferenceBranch)) .Split('\n') .Where(branchName => !string.IsNullOrEmpty(branchName)) .Select(branchName => branchName.Trim('*', ' ', '\n', '\r')) .Where(branchName => branchName != "HEAD" && branchName != context.ReferenceBranch && (!context.IncludeRemotes || branchName.StartsWith(context.RemoteRepositoryName + "/")) && (regex == null || regex.IsMatch(branchName))); }
private static IEnumerable <Branch> GetObsoleteBranches(RefreshContext context, string curBranch) { foreach (string branchName in GetObsoleteBranchNames(context, curBranch)) { context.CancellationToken.ThrowIfCancellationRequested(); var commitLog = context.Commands.RunGitCmd(string.Concat("log --pretty=%ci\n%an\n%s ", branchName, "^1..", branchName)).Split('\n'); DateTime.TryParse(commitLog[0], out var commitDate); var authorName = commitLog.Length > 1 ? commitLog[1] : string.Empty; var message = commitLog.Length > 2 ? commitLog[2] : string.Empty; yield return(new Branch(branchName, commitDate, authorName, message, commitDate < DateTime.Now - context.ObsolescenceDuration)); } }
protected override void RefreshEditor(RefreshContext context, INode figure, MemoShape model) { //if (node.StyledText.Text == "hoge\n" && figure is StyledTextFigure) { // // 動的figure変更のテスト // var fig = new RoundedRect(); // fig.AutoSizeKinds = AutoSizeKinds.GrowBoth; // fig.Text = "hoge"; // _Host.Figure = fig; //} else { //var fig = figure as StyledTextFigure; figure.StyledText = model.StyledText.CloneDeeply() as StyledText; figure.AdjustSize(); //} UpdateMemoMarkHandles(model); }
PendingChangeStatus GetStatus(RefreshContext context, SvnItem item) { SvnStatusData status = item.Status; _kind = CombineStatus(status.LocalNodeStatus, status.LocalTextStatus, status.LocalPropertyStatus, item.IsTreeConflicted, item); if (_kind != PendingChangeKind.None) { return(new PendingChangeStatus(_kind)); } else { return(null); } }
private static IEnumerable<Branch> GetObsoleteBranches(RefreshContext context) { foreach (string branchName in GetObsoleteBranchNames(context)) { context.CancellationToken.ThrowIfCancellationRequested(); var commitLog = context.Commands.RunGitCmd(string.Concat("log --pretty=%ci\n%an\n%s ", branchName, "^1..", branchName)).Split('\n'); DateTime commitDate; DateTime.TryParse(commitLog[0], out commitDate); var authorName = commitLog.Length > 1 ? commitLog[1] : string.Empty; var message = commitLog.Length > 2 ? commitLog[2] : string.Empty; yield return new Branch(branchName, commitDate, authorName, message, commitDate < DateTime.Now - context.ObsolescenceDuration); } }
// --- refresh --- public void Refresh(RefreshContext context) { if (Figure == null || Controller == null) { return; } using (Figure.DirtManager.BeginDirty()) { var containerCtrl = Controller as IContainerController; if (containerCtrl != null && containerCtrl.SyncChildEditors) { RebuildChildren(); } RefreshFigure(context); } }
/// <summary> /// Refreshes the pending change. Returns true if the state was modified, otherwise false /// </summary> /// <param name="context"></param> /// <param name="item"></param> /// <returns></returns> public bool Refresh(RefreshContext context, SvnItem item) { bool m = false; if (!ReferenceEquals(item, SvnItem)) { ReplaceSvnItem(item); } RefreshValue(ref m, ref _iconIndex, GetIcon(context)); RefreshValue(ref m, ref _projects, GetProjects(context)); RefreshValue(ref m, ref _status, GetStatus(context, item)); RefreshValue(ref m, ref _relativePath, GetRelativePath(context)); RefreshValue(ref m, ref _changeList, SvnItem.Status.ChangeList); RefreshValue(ref m, ref _fileType, GetFileType(context, item)); return(m || (_status == null)); }
private static IEnumerable <Branch> GetObsoleteBranches(RefreshContext context, string curBranch) { foreach (string branchName in GetObsoleteBranchNames(context, curBranch)) { context.CancellationToken.ThrowIfCancellationRequested(); var args = new GitArgumentBuilder("log") { "--pretty=%ci\n%an\n%s", $"{branchName}^1..{branchName}" }; var commitLog = context.Commands.GitExecutable.GetOutput(args).Split('\n'); DateTime.TryParse(commitLog[0], out var commitDate); var authorName = commitLog.Length > 1 ? commitLog[1] : string.Empty; var message = commitLog.Length > 2 ? commitLog[2] : string.Empty; yield return(new Branch(branchName, commitDate, authorName, message, commitDate < DateTime.Now - context.ObsolescenceDuration)); } }
protected override void RefreshEditor(RefreshContext context, SimpleRect figure, MemoText model) { if (InUpdating) { return; } if (figure.DragTarget == null) { figure.DragTarget = CreateHostFigureDragTarget(); } if (figure.Padding != DefaultPadding) { figure.Padding = DefaultPadding; } figure.StyledText = (StyledText)model.StyledText.CloneDeeply(); figure.AdjustSize(); UpdateMemoMarkHandles(model); }
/// <summary> /// Creates if pending. /// </summary> /// <param name="context"></param> /// <param name="item">The item.</param> /// <param name="pc">The pc.</param> /// <returns></returns> public static bool CreateIfPending(RefreshContext context, SvnItem item, out PendingChange pc) { if (context == null) { throw new ArgumentNullException("context"); } else if (item == null) { throw new ArgumentNullException("item"); } if (IsPending(item)) { pc = new PendingChange(context, item); return(true); } pc = null; return(false); }
string GetProjects(RefreshContext context) { string name = null; foreach (SccProject project in context.ProjectFileMapper.GetAllProjectsContaining(FullPath)) { ISccProjectInfo info = context.ProjectFileMapper.GetProjectInfo(project); if (info == null) { // Handle the case the solution file is in a project (Probably website) if (string.Equals(FullPath, context.SolutionSettings.SolutionFilename)) { return("<Solution>"); } continue; } if (name != null) { name += ";" + info.UniqueProjectName; } else { name = info.UniqueProjectName; } } if (!string.IsNullOrEmpty(name)) { return(name); } else if (string.Equals(FullPath, context.SolutionSettings.SolutionFilename)) { return("<Solution>"); } else { return("<none>"); } }
private static IEnumerable<string> GetObsoleteBranchNames(RefreshContext context, string curBranch) { RegexOptions options; if (context.RegexIgnoreCase) options = RegexOptions.Compiled | RegexOptions.IgnoreCase; else options = RegexOptions.Compiled; var regex = string.IsNullOrEmpty(context.RegexFilter) ? null : new Regex(context.RegexFilter, options); bool regexMustMatch = !context.RegexDoesNotMatch; string[] branches = context.Commands.RunGitCmd("branch" + (context.IncludeRemotes ? " -r" : "") + (context.IncludeUnmerged ? "" : " --merged " + context.ReferenceBranch)) .Split('\n') .Where(branchName => !string.IsNullOrEmpty(branchName)) .Select(branchName => branchName.Trim('*', ' ', '\n', '\r')) .Where(branchName => branchName != "HEAD" && branchName != curBranch && branchName != context.ReferenceBranch) .ToArray(); return branches.Where(branchName => (!context.IncludeRemotes || branchName.StartsWith(context.RemoteRepositoryName + "/")) && (regex == null || regex.IsMatch(branchName) == regexMustMatch)).ToArray(); }
int GetIcon(RefreshContext context) { if (SvnItem.Exists) { if (SvnItem.IsDirectory || SvnItem.NodeKind == SvnNodeKind.Directory) { return(context.IconMapper.DirectoryIcon); // Is or was a directory } else { return(context.IconMapper.GetIcon(FullPath)); } } else if (SvnItem.Status != null && SvnItem.Status.NodeKind == SvnNodeKind.Directory) { return(context.IconMapper.DirectoryIcon); } else { return(context.IconMapper.GetIconForExtension(SvnItem.Extension)); } }
} // func ImportTableAsync internal Task RefreshTableAsync(RefreshContext context = RefreshContext.ActiveWorkBook) { using (var progress = CreateProgress()) { progress.Report("Aktualisiere Tabellen..."); switch (context) { case RefreshContext.ActiveWorkBook: return(RefreshTableAsync(Globals.ThisAddIn.Application.ActiveWorkbook)); case RefreshContext.ActiveWorkSheet: return(RefreshTableAsync(Globals.ThisAddIn.Application.ActiveSheet)); default: if (Globals.ThisAddIn.Application.Selection is Excel.Range r && !(r.ListObject is null)) { return(RefreshTableAsync(r.ListObject, context == RefreshContext.ActiveListObjectLayout)); } return(Task.CompletedTask); } } } // func RefreshTableAsync
private IEnumerable <string> GetObsoleteBranchNames(RefreshContext context, string curBranch) { RegexOptions options; if (context.RegexIgnoreCase) { options = RegexOptions.Compiled | RegexOptions.IgnoreCase; } else { options = RegexOptions.Compiled; } var regex = string.IsNullOrEmpty(context.RegexFilter) ? null : new Regex(context.RegexFilter, options); bool regexMustMatch = !context.RegexDoesNotMatch; var args = new GitArgumentBuilder("branch") { "--list", { context.IncludeRemotes, "-r" }, { !context.IncludeUnmerged, "--merged" }, context.ReferenceBranch }; var result = context.Commands.GitExecutable.Execute(args); if (!result.ExitedSuccessfully) { MessageBox.Show(this, result.AllOutput, $"git {args}", MessageBoxButtons.OK, MessageBoxIcon.Error); return(Array.Empty <string>()); } return(_commandOutputParser.GetBranchNames(result.AllOutput) .Where(branchName => branchName != curBranch && branchName != context.ReferenceBranch) .Where(branchName => (!context.IncludeRemotes || branchName.StartsWith(context.RemoteRepositoryName + "/")) && (regex == null || regex.IsMatch(branchName) == regexMustMatch))); }
private void RefreshObsoleteBranches() { if (IsRefreshing) { _refreshCancellation.Cancel(); IsRefreshing = false; return; } IsRefreshing = true; var curBranch = _gitUiCommands.GitModule.GetSelectedBranch(); var context = new RefreshContext(_gitCommands, IncludeRemoteBranches.Checked, includeUnmergedBranches.Checked, _referenceBranch, _NO_TRANSLATE_Remote.Text, useRegexFilter.Checked ? regexFilter.Text : null, useRegexCaseInsensitive.Checked ? useRegexCaseInsensitive.Checked : false, regexDoesNotMatch.Checked ? regexDoesNotMatch.Checked : false, TimeSpan.FromDays(_days), _refreshCancellation.Token); Task.Factory.StartNew(() => GetObsoleteBranches(context, curBranch).ToList(), CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default) .ContinueWith(task => { if (IsDisposed || context.CancellationToken.IsCancellationRequested) return; if (task.IsCompleted) { _branches.Clear(); _branches.AddRange(task.Result); _branches.ResetBindings(); } IsRefreshing = false; }, TaskScheduler.FromCurrentSynchronizationContext()); }
private void RefreshObsoleteBranches() { if (IsRefreshing) { refreshCancellation.Cancel(); IsRefreshing = false; return; } IsRefreshing = true; var context = new RefreshContext(gitCommands, IncludeRemoteBranches.Checked, includeUnmergedBranches.Checked, referenceBranch, remote.Text, useRegexFilter.Checked ? regexFilter.Text : null, TimeSpan.FromDays(days), refreshCancellation.Token); Task.Factory.StartNew(() => GetObsoleteBranches(context).ToList(), CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default) .ContinueWith(task => { if (IsDisposed || context.CancellationToken.IsCancellationRequested) return; if (task.IsCompleted) { branches.Clear(); branches.AddRange(task.Result); branches.ResetBindings(); } IsRefreshing = false; }, TaskScheduler.FromCurrentSynchronizationContext()); }