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