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


C# IPackageManager.IsProjectLevel方法代码示例

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


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

示例1: FindPackageToUpdate

        // Find the package that is to be updated.
        public static Tuple<IPackage, IProjectManager> FindPackageToUpdate(
            string id, SemanticVersion version, 
            IPackageManager packageManager,        
            IEnumerable<IProjectManager> projectManagers,
            ILogger logger)
        {
            IPackage package = null;

            // Check if the package is installed in a project
            foreach (var projectManager in projectManagers)
            {
                package = projectManager.LocalRepository.FindPackage(id, version: null);
                if (package != null)
                {
                    return Tuple.Create(package, projectManager);
                }
            }

            // Check if the package is a solution level package
            if (version != null)
            {
                package = packageManager.LocalRepository.FindPackage(id, version);
            }
            else
            {
                // Get all packages by this name to see if we find an ambiguous match
                var packages = packageManager.LocalRepository.FindPackagesById(id).ToList();
                foreach (var p in packages)
                {
                    bool isProjectLevel = packageManager.IsProjectLevel(p);

                    if (!isProjectLevel)
                    {
                        if (packages.Count > 1)
                        {
                            throw new InvalidOperationException(
                                String.Format(CultureInfo.CurrentCulture,
                                    VsResources.AmbiguousUpdate,
                                    id));
                        }

                        package = p;
                        break;
                    }
                    else
                    {
                        if (!packageManager.LocalRepository.IsReferenced(p.Id, p.Version))
                        {
                            logger.Log(MessageLevel.Warning, String.Format(CultureInfo.CurrentCulture,
                                VsResources.Warning_PackageNotReferencedByAnyProject, p.Id, p.Version));

                            // Try next package
                            continue;
                        }

                        // Found a package with package Id as 'id' which is installed in at least 1 project
                        package = p;
                        break;
                    }
                }

                if (package == null)
                {
                    // There are one or more packages with package Id as 'id'
                    // BUT, none of them is installed in a project
                    // it's probably a borked install.
                    throw new PackageNotInstalledException(
                        String.Format(CultureInfo.CurrentCulture,
                        VsResources.PackageNotInstalledInAnyProject, id));
                }
            }

            if (package == null)
            {
                throw new InvalidOperationException(
                    String.Format(CultureInfo.CurrentCulture,
                    VsResources.UnknownPackage, id));
            }

            return Tuple.Create<IPackage, IProjectManager>(package, null);
        }
开发者ID:rikoe,项目名称:nuget,代码行数:82,代码来源:UpdateUtility.cs


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