本文整理汇总了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);
}
}
});
}