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


C# IPackageManager.QueryInstalledVersion方法代码示例

本文整理汇总了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");
        }
开发者ID:rcarz,项目名称:fusion,代码行数:80,代码来源:SearchAction.cs


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