本文整理汇总了C#中Package.AddFlags方法的典型用法代码示例。如果您正苦于以下问题:C# Package.AddFlags方法的具体用法?C# Package.AddFlags怎么用?C# Package.AddFlags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package.AddFlags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Reload
public async Task Reload()
{
_packages.Clear();
await Task.Run(() =>
{
lock (_riLock)
{
dynamic find = _ri.Invoke("Find-Package");
foreach (var result in find)
{
var pkg = new Package(result.Name, result.Name, result.Version, string.Empty, result.Summary,
result.Summary, new List<IPackage>(), new List<IPackage>(), new List<IPackage>(),
new List<string>(), new List<string>(), new List<string>());
_packages.Add(pkg);
}
dynamic get = _ri.Invoke("Get-Package");
foreach (var result in get)
{
var pkg = new Package(result.Name, result.Name, result.Version, string.Empty, result.Summary,
result.Summary, new List<IPackage>(), new List<IPackage>(), new List<IPackage>(),
new List<string>(), new List<string>(), new List<string>());
if (result.Status == "Installed")
{
pkg.AddFlags("installed");
}
var ex = _packages.FirstOrDefault(n => n.Name == pkg.Name && n.Version == pkg.Version);
if (ex != null && result.Status == "Installed")
ex.AddFlags("installed");
else
_packages.Add(pkg);
}
foreach (var package in _packages)
{
var id = package.Id;
var allVersions = Packages.Where(n => n.Id == id).ToList();
package.AddAllVersions(allVersions);
}
}
});
}
示例2: SetUpdatableFlag
private void SetUpdatableFlag(Package package)
{
var latest = _packages.SingleOrDefault(n => n.Id == package.Id && n.Flags.All(m => m != "installed") && n.Flags.Any(m => m == "latest"));
if (latest != null)
{
package.AddFlags("updatable");
}
else
{
package.RemoveFlags("updatable");
}
}