本文整理汇总了C#中IPackageManager.QueryInstalledVersion方法的典型用法代码示例。如果您正苦于以下问题:C# IPackageManager.QueryInstalledVersion方法的具体用法?C# IPackageManager.QueryInstalledVersion怎么用?C# IPackageManager.QueryInstalledVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPackageManager
的用法示例。
在下文中一共展示了IPackageManager.QueryInstalledVersion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Executes this action.
/// </summary>
/// <param name="pkgmgr">package manager instance</param>
public void Execute(IPackageManager pkgmgr)
{
AbstractTree tree = LocalRepository.Read();
List<IPackage> results = tree.Search(_atom, _options.exact);
Console.WriteLine("\n[ Packages found: {0} ]", results.Count);
if (results.Count > 0) {
foreach (IPackage p in results) {
bool fmasked = false;
IDistribution latest = p.LatestUnmasked;
if (latest == null) {
latest = p.LatestAvailable;
fmasked = true;
}
PackageVersion iv = pkgmgr.QueryInstalledVersion(latest.Atom);
string ivstr = iv != null ? iv.ToString() : "[ Not Installed ]";
StringBuilder sizesb = new StringBuilder(11);
Win32.StrFormatByteSize(latest.TotalSize, sizesb, sizesb.Capacity);
Console.Write("\n");
Console.ForegroundColor = ConsoleColor.Green;
Console.Write("*");
Console.ResetColor();
Console.Write(" {0}", p.FullName);
if (fmasked) {
Console.ForegroundColor = ConsoleColor.Red;
Console.Write(" [ Masked ]\n");
Console.ResetColor();
} else
Console.Write("\n");
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(" Latest version available:");
Console.ResetColor();
Console.Write(" {0}\n", latest.Version.ToString());
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(" Latest version installed:");
Console.ResetColor();
Console.Write(" {0}\n", ivstr);
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(" Size of files:");
Console.ResetColor();
Console.Write(" {0}\n", sizesb);
if (!String.IsNullOrEmpty(p.Homepage)) {
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(" Homepage:");
Console.ResetColor();
Console.Write(" {0}\n", p.Homepage);
}
if (!String.IsNullOrEmpty(p.Description)) {
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(" Description:");
Console.ResetColor();
Console.Write(" {0}\n", p.Description);
}
if (!String.IsNullOrEmpty(p.License)) {
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(" License:");
Console.ResetColor();
Console.Write(" {0}\n", p.License);
}
}
}
Console.Write("\n");
}