当前位置: 首页>>代码示例>>C#>>正文


C# IPackageManager.GetInstalledPackagesAsync方法代码示例

本文整理汇总了C#中IPackageManager.GetInstalledPackagesAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IPackageManager.GetInstalledPackagesAsync方法的具体用法?C# IPackageManager.GetInstalledPackagesAsync怎么用?C# IPackageManager.GetInstalledPackagesAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPackageManager的用法示例。


在下文中一共展示了IPackageManager.GetInstalledPackagesAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RefreshPackagesAsync

        private async Task RefreshPackagesAsync(IPackageManager packageManager) {
            if (_suppressPackageRefresh || packageManager == null) {
                return;
            }

            bool prevChecked = _checkedItems;
            // Use _checkingItems to prevent the expanded state from
            // disappearing too quickly.
            _checkingItems = true;
            _checkedItems = true;

            var packages = new Dictionary<string, PackageSpec>();
            foreach (var p in await packageManager.GetInstalledPackagesAsync(CancellationToken.None)) {
                packages[p.FullSpec] = p;
            }

            await ProjectMgr.Site.GetUIThread().InvokeAsync(() => {
                if (ProjectMgr == null || ProjectMgr.IsClosed) {
                    return;
                }

                bool anyChanges = false;
                var existing = AllChildren.OfType<InterpretersPackageNode>().ToDictionary(c => c.Url);

                // remove the nodes which were uninstalled.
                foreach (var keyValue in existing) {
                    if (!packages.Remove(keyValue.Key)) {
                        RemoveChild(keyValue.Value);
                        anyChanges = true;
                    }
                }

                // add the new nodes
                foreach (var p in packages.OrderBy(kv => kv.Key)) {
                    AddChild(new InterpretersPackageNode(ProjectMgr, p.Value));
                    anyChanges = true;
                }
                _checkingItems = false;

                ProjectMgr.OnInvalidateItems(this);
                if (!prevChecked) {
                    if (anyChanges) {
                        ProjectMgr.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_Expandable, 0);
                    }
                    if (ProjectMgr.ParentHierarchy != null) {
                        ExpandItem(EXPANDFLAGS.EXPF_CollapseFolder);
                    }
                }

                if (prevChecked && anyChanges) {
                    var withDb = _factory as IPythonInterpreterFactoryWithDatabase;
                    if (withDb != null) {
                        withDb.GenerateDatabase(GenerateDatabaseOptions.SkipUnchanged);
                    }
                }
            });
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:57,代码来源:InterpretersNode.cs


注:本文中的IPackageManager.GetInstalledPackagesAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。