コード例 #1
0
            private void Provider_StatusUpdated(object sender, SubmoduleStatusEventArgs e)
            {
                _currentSubmoduleInfo = e;

                if (IsAttached)
                {
                    OnStatusUpdated(e);
                }
            }
コード例 #2
0
            private void OnStatusUpdated(SubmoduleStatusEventArgs e)
            {
                ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
                {
                    CancellationTokenSource cts = null;
                    Task <Nodes> loadNodesTask  = null;
                    await ReloadNodesAsync(token =>
                    {
                        cts           = CancellationTokenSource.CreateLinkedTokenSource(e.Token, token);
                        loadNodesTask = LoadNodesAsync(e.Info, cts.Token);
                        return(loadNodesTask);
                    });

                    if (cts != null && loadNodesTask != null)
                    {
                        var loadedNodes = await loadNodesTask;
                        await LoadNodeDetailsAsync(cts.Token, loadedNodes);
                    }

                    Interlocked.CompareExchange(ref _currentSubmoduleInfo, null, e);
                });
            }
コード例 #3
0
            private void OnStatusUpdated(SubmoduleStatusEventArgs e)
            {
                ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
                {
                    CancellationTokenSource?cts = null;
                    Task <Nodes>?loadNodesTask  = null;
                    await ReloadNodesAsync(token =>
                    {
                        cts           = CancellationTokenSource.CreateLinkedTokenSource(e.Token, token);
                        loadNodesTask = LoadNodesAsync(e.Info, cts.Token);
                        return(loadNodesTask);
                    }).ConfigureAwait(false);

                    if (cts is not null && loadNodesTask is not null)
                    {
                        var loadedNodes = await loadNodesTask;
                        await LoadNodeDetailsAsync(loadedNodes, cts.Token).ConfigureAwaitRunInline();
                        LoadNodeToolTips(loadedNodes, cts.Token);
                    }

                    Interlocked.CompareExchange(ref _currentSubmoduleInfo, null, e);
                }).FileAndForget();
            }
コード例 #4
0
            private void OnStatusUpdated(SubmoduleStatusEventArgs e)
            {
                ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
                {
                    CancellationTokenSource?cts = null;
                    Task <Nodes>?loadNodesTask  = null;
                    if (e.StructureUpdated)
                    {
                        _currentNodes = null;
                    }

                    if (_currentNodes is not null)
                    {
                        // Structure is up-to-date, update status
                        var infos = e.Info.AllSubmodules.ToDictionary(info => info.Path, info => info);
                        Validates.NotNull(e.Info.TopProject);
                        infos[e.Info.TopProject.Path] = e.Info.TopProject;
                        var nodes = _currentNodes.DepthEnumerator <SubmoduleNode>().ToList();
                        foreach (var node in nodes)
                        {
                            if (infos.ContainsKey(node.Info.Path))
                            {
                                node.Info = infos[node.Info.Path];
                                infos.Remove(node.Info.Path);
                            }
                            else
                            {
                                // structure no longer matching
                                Debug.Assert(true, $"Status info with {1 + e.Info.AllSubmodules.Count} records do not match current nodes ({nodes.Count})");
                                _currentNodes = null;
                                break;
                            }
                        }

                        if (infos.Count > 0)
                        {
                            Debug.Fail($"{infos.Count} status info records remains after matching current nodes, structure seem to mismatch ({nodes.Count}/{e.Info.AllSubmodules.Count})");
                            _currentNodes = null;
                        }
                    }

                    if (_currentNodes is null)
                    {
                        await ReloadNodesAsync(token =>
                        {
                            cts           = CancellationTokenSource.CreateLinkedTokenSource(e.Token, token);
                            loadNodesTask = LoadNodesAsync(e.Info, cts.Token);
                            return(loadNodesTask);
                        }).ConfigureAwait(false);
                    }

                    if (cts is not null && loadNodesTask is not null)
                    {
                        _currentNodes = await loadNodesTask;
                    }

                    if (_currentNodes is not null)
                    {
                        var token = cts?.Token ?? e.Token;
                        await LoadNodeDetailsAsync(_currentNodes, token).ConfigureAwaitRunInline();
                        LoadNodeToolTips(_currentNodes, token);
                    }

                    Interlocked.CompareExchange(ref _currentSubmoduleInfo, null, e);
                }).FileAndForget();
            }